IsAncestor

Constructor:

IsAncestor(TarObj)

Description

If the instance object is the parent of the specified child object, it returns true. IsAncestor 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 Child 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 via the IsAncestor 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
temp1.Parent = WorkSpace
if WorkSpace:IsAncestor(temp1) then -- judge whether WorkSpace is the parent of temp1 or not        
    temp1.Color = Vector3.New(255,0,0) -- change the color of temp1 into red
end