Volt

getinstances

Returns all instances in the game.

Syntax

getinstances() -> table

Returns

TypeDescription
tableArray of all instances

Description

getinstances returns a table containing every instance currently in the game, including those not in the DataModel hierarchy.

Example

local instances = getinstances()
print("Total instances:", #instances)

-- Count by class
local counts = {}
for _, inst in ipairs(instances) do
    local class = inst.ClassName
    counts[class] = (counts[class] or 0) + 1
end

for class, count in pairs(counts) do
    print(class, count)
end

Finding Specific Instances

-- Find all Scripts
local scripts = {}
for _, inst in ipairs(getinstances()) do
    if inst:IsA("Script") then
        table.insert(scripts, inst)
    end
end

Notes

  • Returns a very large table
  • Includes nil-parented instances
  • May impact performance if called frequently

On this page