getluastate Synchronous

Resolve the Luau state associated with an Actor or script Instance. With no argument, it resolves the current state instead.

Syntax
Luau
getluastate(instance: (Actor | ScriptInstance)?) -> LuaStateProxy?

Parameters

Function parameters
ParameterTypeDescription
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.

LuaStateProxy fields
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

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
Kawaii documentation