generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Whats the use of . . .

Previous Thread :: Next Thread 
szkiller_dev is not online. szkiller_dev
Joined: 07 Oct 2016
Total Posts: 3572
04 Dec 2016 01:12 AM
Whats the main use of waitforchild() ???
Report Abuse
iOpticalDecryption is not online. iOpticalDecryption
Joined: 09 Dec 2014
Total Posts: 23
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
samuelgp10 is not online. samuelgp10
Joined: 13 Jul 2011
Total Posts: 74
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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Dec 2016 01:59 AM
^
Report Abuse
szkiller_dev is not online. szkiller_dev
Joined: 07 Oct 2016
Total Posts: 3572
04 Dec 2016 04:18 AM
My guess was right xD
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image