API:Class/Instance/Parent

Parent

Property of Object Icon.pngInstance

Value Type: Ref<Instance>
Description: This property shows the hierarchical parent of an object. This property is also used to manage whether an object exists in the game or needs be be removed. As long as an object’s parent is in the DataModel, is stored in a variable, or is referenced by another object’s property, then the object will remain in the game. Otherwise, the game engine will automatically remove the object.For example, after using Instance.new to create an object the object’s parent is nil. Unless the object is assigned a parent, such as game.Workspace, it will no longer exist once the variable pointing to it has been removed. The top level DataModel object (the one referred to as the "game" by scripts) has no parent, but always has a reference held to it by the game engine, and exists for the duration of a session.

Example

print(game.Parent)
--> nil
 
print(Workspace.Parent)
--> game

See Also

Instance Hierarchy