DescendantAdded

Constructor:

DescendantAdded(descendantobject)

Description

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

Parameters

Name Type Description
descendantobject RWObject The descendant object that is added

Examples

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

local folder = RWObject.Create("Folder") -- create folder1
folder.Parent = WorkSpace
local folder2 = RWObject.Create("Folder") -- create folder2
folder2.Parent = folder
folder.DescendantAdded:Connect(function(child) -- triggered when the child object is added under the folder
 child.Color = Vector3.New(255,0,0)
end)
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