runonactor(actor, code, ...) / runonthread(thread, code) / run_on_thread(thread, code)
Runs code on an Actor or on a thread's state.
Syntax
runonactor(actor: Instance, code: string, ...any) -> ()
runonthread(thread: thread, code: string) -> ()
Parameters
| Parameter | Type | Description |
|---|---|---|
actor | Instance | Actor instance for runonactor. |
thread | thread | Target thread for runonthread/run_on_thread. |
code | string | Luau source. |
Returns
| Type | Description |
|---|---|
() | No return values. |
Description
runonactor queues the code on the actor's state with actor-specific environment and communication globals.
Logic change: runonthread and run_on_thread are no longer aliases of runonactor. They create a child thread of the target thread's state, inherit its globals and identity, load the code and resume it, so a thread (not an Instance) is accepted.
Example
local t = task.spawn(function() task.wait(2) end)
runonthread(t, "shared.flag = true")