Returns the first child node of the given class. 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
className string Class 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 of the given class, 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
function s() -- define the method s
    local temp1 = WorkSpace:GetChildByClassName("Part") -- seek the first child node NewBackground under WorkSpace
    temp1.Color = Vector3.New(255,0,0) -- change the color of NewBackground
temp.CollisionEnter:Connect(s) -- when temp is touched, call the s method to change color.