Yuari
Documentation
Docs/Actors/runonactor

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

ParameterTypeDescription
actorInstanceActor instance for runonactor.
threadthreadTarget thread for runonthread/run_on_thread.
codestringLuau source.

Returns

TypeDescription
()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")