DescendantRemoved

Constructor:

DescendantRemoved(descendantobject)

Description

Triggered when a descendant object is removed, including direct child objects and indirect objects.

Parameters

Name Type Description
descendantobject RWObject The descendant object is removed

Examples

Create a three-hierarchy structure and the third hierarchy is part object. Change the part color when the part is removed.

local folder = RWObject.Create("Folder") -- create folder1
folder.Parent = WorkSpace
local folder2 = RWObject.Create("Folder") -- create folder2
folder2.Parent = folder
local part = RWObject.Create("Part") -- create a part object
part.Position = Vector3.New(1,2,1)
part.Parent = folder2 -- set the part object as the child of folder2
folder.DescendantRemoved:Connect(function(child) -- triggered when the child object is removed from the folder
    child.Color = Vector3.New(255,0,0)
end)
wait(3)
part.Parent = WorkSpace -- move the part object from folder2 to WorkSpace.