GetChildByName(Name, Recursive)


Returns the first child node with the given name. If there is no child with the given name, this function returns nil. If the optional recursive parameter Recursive is true, this function will search through all descendants, instead of only searching among its immediate children.


Variable name Type Default Description
Name string Name of child node to seek
Recursive bool false Search recursively or not. If not filled in, it defaults to false.

Return Value

Type Description
RWObject Returned child object. If no child with the given name, return nil.


Create an instance object of a part. When this object is hit, change the new background color.

local temp = RWObject.Create("Part") -- create an instance "temp" of Part
temp.Name = "1" -- define the name of temp
temp.Position = Vector3.New(0,1,2) -- define the position of temp
temp.Anchored = true -- temp is anchored
temp.Parent = WorkSpace
function CHANGE() -- define the method CHANGE
    local temp1 = WorkSpace:GetChildByName("NewBackground") -- seek the first child node NewBackground under WorkSpace
    temp1.Color = Vector3.New(255,0,0) -- change the color of NewBackground
temp.CollisionEnter:Connect(CHANGE) -- when temp is touched, call the s method to change color.