Seeks its own child object. When no child object exists, if the parameter timeout is not filled in, the process will be suspended until a child object is found. If "timeout" is filled in, the process will be suspended the time specified by the parameter before resuming to running.
WaitForChild is very important in handling the code running on the client. The ReWorld editor does not guarantee the time when the objects are copied from the server to the client and the copying sequence. This may lead to an interrupt when the script is indexing an object that does not exist yet.
|childName||string||The name of the object that needs to find|
|RWObject||The child object that is found|
Create a part. Wait by using WaitForChild() until the part is created, and then change its color.
local temp = RWObject.Create("Part") -- create a part temp.Name = "NewPart" temp.Position = Vector3.New(0,4,0) temp.Color = Vector3.New(1,1,1) -- the color of the part is black temp.Anchored = true temp.Parent = WorkSpace local findpart = WorkSpace:WaitForChild("NewPart") -- wait in WorkSpace until the part finishes loading findpart.Color = Vector3.New(255,0,0) -- set its color to red