|
| 04 Dec 2016 01:12 AM |
| Whats the main use of waitforchild() ??? |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2016 01:18 AM |
local parentChildren = script.Parent:GetChildren()
for i = 1,#parentChildren do script.Parent[i]:WaitForChild() end
This will wait until all the children of the scripts parent have fully loaded in.
It's particularly useful in LocalScripts because (at least in my case) most of the time clients don't load as fast and when you try to declare/set/whatever a variable that's set to, let's say an object, because it hasn't loaded yet it's nil, and then when you try to use that variable, you get an error in your script.
Tl;dr It waits for stuff to load basically.
|
|
|
| Report Abuse |
|
|
|
| 04 Dec 2016 01:30 AM |
Waits for the child of an object to load...
Like
[Parent] waitforchild("object") [children] none local p = Instance.new("Part", Parent) [childadded] p.Name = "object" [yield end] [script continues]
[S1O Was Here] |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 04 Dec 2016 01:53 AM |
"local parentChildren = script.Parent:GetChildren()
for i = 1,#parentChildren do script.Parent[i]:WaitForChild() end"
This is not only invalid use of it but also an invalid theoretical use of it.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
| |
|