VINDICTA
Actors · Function Unregistered
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

run_on_actor

Runs code inside an actor's global state.

Unregistered
This function is not registered within sUNC, your executor may/may not have this.
function run_on_actor(actor: Actor?, script: string, channel_data?: any): ()

Synopsis

How it works

Injects and executes a Luau script string inside the specified Actor’s parallel execution context. If actor is nil, a new temporary Actor is created. The script runs on the Actor’s lua_State, giving it access to that Actor’s environment and parallel execution capabilities.

Communication

Use channel_data to pass initial data to the injected script. For ongoing communication, use create_comm_channel() to set up a BindableEvent-based message channel between the main thread and the Actor.

Usage

Simple execution
run_on_actor(getactors()[1], 'print("Hello World!")')
Transfer data via comm channel
local comm_id, event = create_comm_channel()
event.Event:Connect(function(data)
    print(data) "cc">-- -> Hello World!
end)
run_on_actor(getactors()[1], [=[
    local channel = get_comm_channel(...)
    channel:Fire('Hello World!')
]=], comm_id)

Parameters

actor Actor?
The actor to execute code inside of. Nil runs in the default state.
script string
The Luau source code to execute.
channel_data any optional
Data passed as ... to the script. Cannot be tables or functions (different Lua VM).
VM Boundary
You cannot pass tables or functions across actor boundaries as they belong to a different Lua VM.