GetAllChild

Constructor:

GetAllChild()

Description

Returns an array, containing all direct children of the object or all instances whose parents equal to this object. The array can be iterated over by using a number or a general for-loop.

Return Value

Type Description
table The table that contains all child objects

Examples

Return an array that contains all direct child nodes.

    local temp = RWObject.Create("Part") -- create a part
    local temp2 = RWObject.Create("Folder") -- create a folder
    temp.Position = Vector3.New(3,3,3) -- set the coordinates of the part and anchor it
    temp.Anchored = true
    temp.Parent = WorkSpace -- set the parents of the part and the folder as WorkSpace
    temp2.Parent = WorkSpace
    for i = 1,4 do -- clone the part by using for-loop
        temp1 = temp:Clone()
        temp1.Name = tostring(i) -- clone the part and name it with the times of clone
        temp.Position = Vector3.New(3+i,3,3+i) -- set the coordinates of the part according to the times of clone
        temp1.Parent = temp2 -- all the parents of cloned parts are the folder temp2
    end
    for _,Child in pairs(temp2:GetAllChild()) do -- use pairs to iterate through the table of all child objects that is generated by using GetAllChild() to temp2
        Child.Color = Vector3.New(255,0,0) -- set the child object color to red
    end