IsDescendant

Constructor:

IsDescendant(TarObj)

Description

If the instance object is the child of the specified parent object, it returns true. The recursive search function IsDescendant cannot be used with the parameter nil in checking whether the object has been deleted or not.

Parameters

Variable name Type Default Description
TarObj RWObject Parent object specified for judgment

Return Value

Type Description
bool The judgment result returned, True or False

Examples

Create a part, and access to it from its parent object via the IsDescendant function.

local temp1 = RWObject.Create("Part") -- create a part and assign it to the variable temp1
temp1.Position = Vector3.New(3,2,3) -- define the position of temp1
temp1.Anchored = true -- anchor temp1
if temp1:IsDescendant(WorkSpace) then -- judge whether temp1 is the child of WorkSpace        
   temp1.Color = Vector3.New(255,0,0) -- change the color of temp1 into red
end