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 » Game Design
Home Search
 

Re: Difference between FindFirstChild and WaitForChild?

Previous Thread :: Next Thread 
phoniex is not online. phoniex
Joined: 03 Feb 2008
Total Posts: 34985
09 Apr 2015 05:01 PM
Title says all. I've seen both of these functions used a lot, but I'm not really sure what the difference between them is.

~Rock is dead. Long live paper and scissors!~
Report Abuse
SummerEquinox is online. SummerEquinox
Joined: 25 Jun 2013
Total Posts: 2088
09 Apr 2015 05:13 PM
FindFirstChild finds the first child in the specified area with that name.

WaitForChild will wait until that specific child name appears, example: it could wait for some kind of ("Instance.new")
Report Abuse
phoniex is not online. phoniex
Joined: 03 Feb 2008
Total Posts: 34985
09 Apr 2015 05:16 PM
@Summmer

That makes sense. Thanks for the help.

~Rock is dead. Long live paper and scissors!~
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 06:51 PM
FindFirstChild: returns the first child with the name you specified, or nil if it doesn't exist

WaitForChild: yields the script until the instance with the name you specified is found. Be wary though as WaitForChild does not take into account name changes of instances. More info below..


http://wiki.roblox.com/index.php?title=API:Class/Instance/FindFirstChild
http://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 06:54 PM
For example:

wait(1)
local object=script.Parent:WaitForChild("Hello")
print("Found the object!")


FindFirstChild:

wait(1)
local object=script.Parent:FindFirstChild("Hello")
if object then --checking that the object exists, and FindFirstChild didn't return nil. Always check or your script can break.
print("Found the object!")
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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