Parent (Property): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>XLEGOx
No edit summary
Fix syntax highlight
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{redirect|Parent|parents|the individuals (as in your Mom or Dad)}}
<onlyinclude>{{Property
<onlyinclude>{{Property
|name        = Parent
|name        = Parent
|property    = [[Instance|Object]] ''An object's parent''
|type        = {{type|instance=Instance}}
|description = The hierarchical parent of the object. When no scripts hold references to an object, it will still be maintained as long as it's parent is set to an object which does have references to it, either by other objects or scripts. The toplevel [[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.
|description = The hierarchical parent of the object. When no scripts hold references to an object, it will still be maintained as long as it's parent is set to an object which does have references to it, either by other objects or scripts. The toplevel [[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.
|object      = Instance
|object      = Instance
Line 8: Line 9:
{{clear floats}}
{{clear floats}}


{{Example|<pre>
{{Example|<syntaxhighlight lang="lua">
print(script.Parent.Name)
print(script.Parent.Name)
-- "Workspace" should appear in the output window (only if the script
-- "Workspace" should appear in the output window (only if the script is located under Workspace).
is located under Workspace).
</syntaxhighlight>}}
</pre>}}


== See Also ==
== See Also ==

Latest revision as of 03:25, 18 April 2023

"Parent" redirects here. For the individuals (as in your Mom or Dad), see parents.
Parent
Type Instance
Description The hierarchical parent of the object. When no scripts hold references to an object, it will still be maintained as long as it's parent is set to an object which does have references to it, either by other objects or scripts. The toplevel 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.
Member of Instance


Example
print(script.Parent.Name)
-- "Workspace" should appear in the output window (only if the script is located under Workspace).


See Also

Instance Hierarchy