What does :FindFirstChild mean?
FindFirstChild
identifies the "first" child (or descendant if the optional second argument is specified as true
) which has the name given in the parameter.
Wiki article on FindFirstChild
The "first" doesn't really mean anything useful; as long as there is only one such child (or descendant*) with that name, it will return that child.
If there is not such object with that name, FindFirstChild
returns nil
. This can be contrasted with simple indexing using .name
or ["name"]
which will trigger an error. Therefore if you are unsure whether or not a child may exist in an object, you should use FindFirstChild
so that errors will not occur.
print( game:FindFirstChild("Workspace") == game.Workspace ); -- true