Do you have to wait for the tool to load soon as though I'm using a LocalScript?

I am using a LocalScript to reference the tool, do I need to use a :WaitForChild() to wait for the tool to load in or do I not need to wait for the tool to load in?

local tool = script.Parent

OR

local tool = script.Parent.Parent:WaitForChild("Tool")
1 Like

Yes, you must. It is important to use WaitForChild when referencing objects client wise, as we cannot guarentee when the object loads in.

DevForum -

Roblox does not guarantee the time or order in which objects are replicated from the server to the client. This can cause scripts to break when indexing objects that do not exist yet.

1 Like

Use the first option. The child always loads after the parent so it should never error in this case.

I knew it. Just clarifying and thanks for letting me know.

So if I reference objects on the server-side, I don’t need to wait for it to load in (I don’t need :WaitForChild)?

But using :WaitForChild() won’t cause any errors will it?

It won’t but it’s unneeded in this case as you’re referencing script.Parent.

1 Like

If you’re referencing it on the server-side, you won’t need to use :WaitForChild()

1 Like

Nope, you don’t have to, as long as it is server side

1 Like