ReferenceActors

run_on_actor

Submits Luau source to an eligible Actor’s state.

Syntax

run_on_actor(actor: Actor, source: string, ...: any) -> ()

Also available as

runonactor

Parameters

ParameterTypeDescription
actorActorObserved Actor with an available state.
sourcestringLuau chunk to compile in the destination.
...anySupported values transferred as chunk arguments.

Description

Source is compiled and scheduled in the destination state. Extra arguments are transferred and become the submitted chunk's varargs. The call does not return the chunk's results. A local function value is not source text; pass a string. Source is limited to 1 MiB and at most 64 extra arguments. An Actor that has never run a script has no state of its own: the compatibility fallback places an empty client Script named Script inside it, which makes the engine create the state, and retries for up to three seconds. The fallback Script is not removed after the state appears. Inside an Actor the same call is also published as runonactor, and get_comm_channel as getcommchannel. An unavailable Actor state, excessive source or unsupported transferred value raises an error.

The destination has its own environment. Do not assume tables, closures or ordinary thread handles are shared across states; use create_comm_channel for explicit communication.

Example

local actor = getactors()[1]
if actor then
    run_on_actor(actor, "local value = ...; print(value)", "hello")
end

These are Game executor contracts. Check build requirements and session lifetimes before using them.