Volt

LuaStateProxy:GetActors

Returns all Actor instances associated with this Lua state.

Syntax

state:GetActors() -> {Actor}

Parameters

This method takes no parameters.

Returns

TypeDescription
{Actor}Array of Actor instances for this state

Description

LuaStateProxy:GetActors returns all Actor instances that are associated with this Lua state. For actor states, this will return the actors using that state. For the game state, this will return an empty array.

Example

local state = getluastate()
local actors = state:GetActors()

print("Actors in state:", #actors)
for i, actor in ipairs(actors) do
    print(i, actor:GetFullName())
end

Actor State Example

local actor = Instance.new("Actor")
actor.Parent = workspace

local actorState = getluastate(actor)
local actors = actorState:GetActors()

-- Should contain the actor we just created
for _, a in ipairs(actors) do
    print("Actor:", a:GetFullName())
end

Filter by State

local allStates = getactorstates()

for _, state in ipairs(allStates) do
    if state.IsActorState then
        local actors = state:GetActors()
        print("State", state.Id, "has", #actors, "actors")
    end
end

On this page