I'm curious, what are the difference between FindFirstChild and WaitForChild?
what's the difference between FindFirstChild and WaitForChild?
1 answer
Easy.
FindFirstChildgives out a string value ("value"), if the selected child exists, or nil if no such child exists.
Example
local something = script.Parent:FindFirstChild("ChildName")
print(something)
--if a child with the given name exists, it will print it's name. Else, it will print nil.
Before we continue to WaitForChild, I have to say a thing. FindFirstChild has a bool property. If you do not type it, it will be false by deflaut. IF true, it will search for every descendant.
local something = script.Parent:FindFirstChild("ChildName", true)
print(something)
--if a descendant with the given name exists, it will print it's name. Else, it will print nil.
--if the hierarchy is like this (script.Parent.ChildNameA.Dakiy.ChildName), and bool recursive is true, it will print the child name and not nil. If false, it will just print the child name if the hierarchy is like that (script.Parent.ChildName), else it will print nil
WaitForChilddoes the same, but, if no child detected, it will wait until a child with the given name appears. And it has not the bool recursive
local something = script.Parent:WaitForChild("ChildName")
print(something)
--Basicly, it will never print nil, because if no child with the correct name, the function will yield until a child with the given name appears. Then, it will print it's name.
3 comments
There is one additional difference: WaitForChild will not trigger if something's Name property is changed. WaitForChild listens to the ChildAdded event, and only looks at the Child actually added.
Cool!
@adark: I believe that is changed/is going to be changed soon, reducing lots of headaches!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
FindFirstChild find the object your looking for and if it can't find it will return nil and WaitForChild wait till the Object your looking for exist.
The different between the two is that: 'FindFirstChild' will check to see if the Child exists within the Parent, if not, then it will return a 'nil' value, while 'WaitForChild' will yield the code until a Child with the same (exact) Name as the Argument is existant within the Parent, and will not return 'nil'.