Actors

run_on_thread

Runs Luau source on a specific Luau thread.

Syntax

run_on_thread(thread: thread, source: string, ...arguments?: ...any)
Aliases runonthread

Arguments

NameTypeDescription
threadthreadTarget Luau thread used to run the source.
sourcestringNon-empty Luau source string to run on the target thread.
...arguments?...anyAdditional values passed to the dispatched source when supported. Unsupported values are passed as nil.

Description

Runs Luau source on a specific Luau thread. Extra arguments after source are passed to the dispatched source when supported. The call returns no values and does not return values produced by the dispatched source. runonthread is an alias.

Call it with 3 parameter(s): thread, source, ...arguments. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Run source on a target Luau thread.

local thread = getactorthreads()[1]

if thread then
    run_on_thread(thread, [[
        print(getcurrentactor())
    ]])
end