PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

IsDescendantOf

Returns true if an Instance is a descendant of the given ancestor.

An Instance is considered the descendant of an object if the Instance's parent or one of its parent’s parent is set to the object.

Note, DataModel is a descendant of nil. This means IsDescendantOf cannot be used with a parameter of nil to check if an object has been removed.

See also, Instance/IsAncestorOf.

Parameters

Name Type Default Description

The ancestor Instance.

Returns

Return Type Summary

True if the Instance is a descendant of the given ancestor.


Code Samples


Instance:IsDescendantOf

local part = Instance.new("Part")
print(part:IsDescendantOf(game))
--> false

part.Parent = game.Workspace
print(part:IsDescendantOf(game))
--> true

part.Parent = game
print(part:IsDescendantOf(game))
--> true