API:Class/Instance/Remove

Remove

Deprecated: This item is deprecated. Do not use it for new work.
Function of Object Icon.pngInstance
void Remove ()

Returns: void
Description: Sets the object's Parent to nil, and does the same for all its descendants.

Notes

  • This item is deprecated in favor of Destroy and ClearAllChildren. If you must remove an object from the game, and wish to use the object later, set its Parent property to nil instead of using this method.
  • If the object is referenced before being removed it is possible to retrieve the object at a later point.

Example

The following code demonstrates how a part can be re-added to the DataModel after being removed:

local part = Instance.new("Part", Workspace)
print(part.Parent)
--> Workspace
 
part:Remove()
print(part.Parent)
--> nil
 
part.Parent = Workspace
print(part.Parent)
--> Workspace