Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the difference between waitfirstchild and findfirstchild?

I searched up many forums about it but I just dont get it. If waitfirstchild is just going to find the child if it exists and findfirstchild is just going to find the child if it exists as well then what is the difference. I know that findfirstchild is instantly going to find the child but waitfirstchild is still also going to find the child instantly if it exists as well. Does anybody know the difference? Please help.

2 answers

✓ Accepted answer

:WaitForChild("Part") is for waiting for a part mostly to load
:FindFirstChild("Part")for example if you have in workspace 2 parts that are have similar names when you say:FindFirstChild("Part") it will find the first part that has this name

Also its very usfull cause if it finds the part it returns "true" and if the part dosnt exsist it return "false" so if you are using :FindFirstChild() you can put it in a if statement

Exsample:

if game.Workspace:FindFirstChild("Part")then
	print(game.Workspace.Part.Name)
else
	print("No part in workspace called part")
end

1 comment

0

FindFirstChild does not return a boolean but the instance of the part.

Hello, RebornedSnoop!

Both of them are used to find a child of an Instance.

The only difference is that WaitForChild waits for the Child to be created, so it don't errors(but may cause infinite wait warnings), while FindFirstChild tryes to match only the existing childs, and may cause errors if the part you're trying to find don't exists

5 comments

0

So waitforchild is literally findfirstchild but waits?

0

yes

0

no

0

RebornedSnoop read my answer and you might understand

0

ok thanks sorry but only can accept one

This discussion is preserved as it was. New answers, comments, and votes are closed.