API:Class/Instance/IsDescendantOf

IsDescendantOf

Function of Object Icon.pngInstance
bool IsDescendantOf (
    Instance ancestor
)
Parameters:
  1. ancestor

Returns: bool
Description: Returns true if the object is a descendant of the given ancestor.

Notes

  • Because the DataModel.pngDataModel is a descendant of nil, you cannot use Instance:IsDescendantOf(nil) to check if an object has been removed.
    Instead, you could use: not Instance:IsDescendantOf(game)

Example

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