ReferenceInstances

getnilinstances

Lists Instances that exist but are not in the game tree.

Syntax

getnilinstances() -> {Instance}

Also available as

get_nil_instances

Returns

TypeDescription
{Instance}Every referenced Instance whose Parent is nil.

Description

Games often keep objects parented to nil to hide them from game:GetDescendants(), then move them in when needed. This returns those objects.

Example

for _, object in getnilinstances() do
    print(object.ClassName, object.Name)
end

These are Game executor contracts. Check build requirements and session lifetimes before using them.