getluastate Synchronous
Resolve the Luau state associated with an Actor or script Instance. With no argument, it resolves the current state instead.
Luau
getluastate(instance: (Actor | ScriptInstance)?) -> LuaStateProxy?Parameters
| Parameter | Type | Description |
|---|---|---|
instance | (Actor | ScriptInstance)? | Optional Actor, Script, LocalScript, or ModuleScript. Omit to inspect the current state. |
Returns
LuaStateProxy?A LuaStateProxy when the state can be found; otherwise nil.
Luau
LuaStateProxy = {Id: number, IsActorState: boolean, Event: NativeSignal}Usage notes
A script without a discoverable active state returns nil. Other Instance classes raise an argument error.
Example
Luau
local current = getluastate()
print("Current state:", current and current.Id)
local actor = getactors()[1]
if actor then
local state = getluastate(actor)
print("Actor state:", state and state.Id)
end