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 » Scripting Helpers
Home Search
 

Re: how to use WaitForChild?

Previous Thread :: Next Thread 
Joeza8901 is not online. Joeza8901
Joined: 24 Feb 2009
Total Posts: 58
20 May 2013 08:40 AM
hi, I'm learning some basic scripting now and I have no idea what this actually does..

local billboard = WaitForChild(Zone, 'BillboardGui')

I thought that it's the same as

local billboard = Zone.BillboardGui

am I right?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
20 May 2013 08:48 AM
Well you should use WaitForChild only if you know that the object might not be there instantly, but might have a little delay until it appears there.


local billboard = zone:WaitForChild( 'BillboardGui')
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
20 May 2013 10:58 AM
WaitForChild is a great help with respawning characters, because the characters don't respawn instantly. So if your script said char=player.Character and the character hadn't fully respawned, then it would break.
So use it to wait for an object to appear.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
20 May 2013 11:09 AM
@jarod


game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
print(player.Name.." respawned.")
end)
end)


--or


humanoid.Died:connect(function()
char = game.Players.GetPlayerFromCharacter(humanoid.Parent).CharacterAdded:wait()
humanoid = char:WaitForChild("Humanoid")
end)
Report Abuse
bigdaddy92 is not online. bigdaddy92
Joined: 17 Jan 2010
Total Posts: 1684
20 May 2013 11:11 AM
WaitForChild is a method used to wait for a child to be parented into an Instance, and is very useful if you want to wait for an instance to be there, but not right as the script is running. Once the instance is found, the method then returns that instance, for use.

-bigdaddy92
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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