ClearAllChildren
Destroys every direct child of the instance.
Syntax
inst:ClearAllChildren() -> nil
Parameters
This function takes no parameters.
Returns
| Type | Description |
|---|---|
| - | No return value. |
Description
The VM reparents each direct child to nil, which is the same operation as calling :Destroy() on it; grandchildren go with their parent.
The call is instant and cannot be undone.
Example
local folder = Instance.new("Folder", workspace)
Instance.new("Part", folder)
Instance.new("Part", folder)
folder:ClearAllChildren()
print(#folder:GetChildren()) -- 0
Notes
inst:ClearAllChildren()— Only direct children are touched; the instance itself stays parented.