getinstances
Lists every Instance referenced from Luau, including ones outside the game tree.
Syntax
getinstances() -> {Instance}
Also available as
get_instances
Returns
| Type | Description |
|---|---|
{Instance} | Every Instance the client currently has a Luau reference for. |
Description
The list includes objects parented to nil, objects in hidden containers and objects other scripts created and kept. It is a snapshot of the Instance cache at the moment of the call.
Example
local count = 0
for _, object in getinstances() do
if object:IsA("RemoteEvent") then
count += 1
end
end
print(count, "RemoteEvents")
Notes
- An Instance no script has ever touched may have no Luau reference yet, and then does not appear.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
