> ## Documentation Index
> Fetch the complete documentation index at: https://docsuncv2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# getnilinstances

Returns the Instances Roblox is holding alive that are not currently parented in the game hierarchy.

```luau theme={null}
getnilinstances(): {Instance}
```

These are usually Instances a script created with `Instance.new` and never gave a parent, or Instances the game detached from `workspace` but a reference is still holding onto.

Every Instance `getnilinstances` returns is also in `getinstances()`'s result - `getnilinstances` is the floating-in-memory slice of the same set.

## Returns

`{Instance}` - an array of Instances with no spot in the game hierarchy. Order is not guaranteed.

## Example

A client anti-cheat <a href="https://discord.com/channels/1395020539915014185/1395020539915014188/1498234542266253374">may unparent itself</a> to stay out of `game` traversal. `getnilinstances` still returns it, so you can walk the list and inspect every detached Instance:

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  local nilInstances = getnilinstances()
  =======
  -- getnilinstances(): {Instance}
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  for _, inst in ipairs(getnilinstances()) do
      print(`{inst.ClassName}: {inst:GetFullName()}`)
  end
  ```
</CodeGroup>

<Tip>
  Useful for finding garbage collected objects or scripts stored in nil.
</Tip>
