run_on_thread(thread: thread, script: string, ...): ()
Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread | The thread whose context should be used for execution. |
script | string | The Luau code string to run. |
... | any | Arguments to pass to the running code. |
Returns
void
Example
-- Execute a print statement on the first actor thread
local threads = getactorthreads()
if #threads > 0 then
run_on_thread(threads[1], "print('Hello from actor thread context')")
end
-- Pass arguments and run code on a thread
local threads = getactorthreads()
if #threads > 0 then
run_on_thread(threads[1], "local arg1 = ...; print('Received argument:', arg1)", "data_test")
end
Allows interacting with running threads or parallel actor contexts directly by executing code inside them.