Volt

getluastate

Returns the LuaStateProxy for a given Actor or loaded script.

Syntax

getluastate(actor_or_script: (Actor | BaseScript)?) -> LuaStateProxy

Parameters

ParameterTypeDescription
actor_or_scriptActor | BaseScript?The Actor or script to get the state for. If omitted, returns current state

Returns

TypeDescription
LuaStateProxyThe LuaStateProxy for the given Actor or script, or current state

Description

getluastate returns the LuaStateProxy object for a specific Actor or loaded script. If no argument is provided, it returns the LuaStateProxy for the current Lua state.

Example

-- Get current state
local currentState = getluastate()
print("Current state ID:", currentState.Id)

-- Get state for an actor
local actor = Instance.new("Actor")
actor.Parent = workspace
local actorState = getluastate(actor)
print("Actor state ID:", actorState.Id, "Is Actor:", actorState.IsActorState)

Get State for Script

-- Get state for a specific script
local script = workspace.SomeScript
local scriptState = getluastate(script)
print("Script state ID:", scriptState.Id)

Access State Properties

local state = getluastate()
print("State ID:", state.Id)
print("Is Actor State:", state.IsActorState)

-- Get all actors for this state
local actors = state:GetActors()
print("Actors in state:", #actors)

On this page