LuaStateProxy: Execute Asynchronous
Run Luau source in the state represented by this proxy. Pass simple values or Instances when the target code needs context from the caller.
Luau
LuaStateProxy:Execute(source: string, ...args: CrossStateValue) -> ()Parameters
Call this method with a LuaStateProxy receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
source | string | Luau source string compiled in the target state. |
...args | CrossStateValue | Values made available to the source through varargs. |
Argument fields
Luau
CrossStateValue = nil | boolean | number | string | Instance | {[CrossStateValue]: CrossStateValue}Returns
()No value.
Usage notes
The source starts in the target state and runs until it finishes or first yields. This call does not return the chunk’s results; later work can continue in the target state.
Only nil, booleans, numbers, strings, Instances, and tables of those values can cross states. Functions, threads, buffers, and other userdata cannot.
Example
Luau
local state = LuaStateProxy.new()
state:Execute('local message = ...; print(message)', "Hello from this state")