Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Explanation of :WaitForChild?

Asked by 10 years ago

What does :WaitForChild mean?

1 answer

Log in to vote
2
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

By textbook (wiki) definition it says;

Yields the current thread until a child with the Name property of name is found, then returns it.

So it basically waits until the item named in the string, for example "Tool", is existent in the location.

game.Workspace:WaitForChild("Tool")

Once it is existent, it will do it the action you requested on it. So let's say we destroy it,

game.Workspace:WaitForChild("Tool"):Destroy()

The method will wait for the object "Tool" to show up in workspace, then you can change the properties of the object or execute another method on top of it.

0
WaitForChild basically repeteadly calls FindFirstChild and, well, waits until something is finally returned by it. adark 5487 — 10y
Ad

Answer this question