getinstances
Returns every Instance tracked by the Luau garbage collector.
function getinstances(): {Instance}Synopsis
How it works
Walks the Luau GC's object list and collects every
userdata that wraps a Roblox Instance. This includes InstancesInstanceThe base class for all Roblox objects (Parts, Models, Scripts, GUIs, etc.). Instances form a tree hierarchy (the DataModel). In Luau, they appear as userdata with shared metatables. parented to nil, hidden services, the executor's GUI container, and everything in the DataModelDataModelThe root Instance in Roblox's object hierarchy (game). Contains all services (Workspace, Players, ReplicatedStorage, etc.). Teleporting destroys the current DataModel and creates a new one.. Returns a complete inventory of every Instance reference currently alive in memory.Performance
A typical Roblox game has 10,000–60,000+ InstancesInstanceThe base class for all Roblox objects (Parts, Models, Scripts, GUIs, etc.). Instances form a tree hierarchy (the DataModel). In Luau, they appear as userdata with shared metatables.. The returned array is large. Always filter immediately using
:IsA() or .ClassName checks rather than storing the full array.Usage
Find all RemoteEvents
for _, inst in ipairs(getinstances()) do
if inst:IsA("RemoteEvent") then
print(inst:GetFullName())
end
endReturns
{Instance} Array of every Instance known to the GC.
Performance
This can return thousands of objects. Filter results immediately rather than storing the whole array.