WaitForChild outputs errors on studio

It prints this message when I open studio.

21:47:48.321 - Infinite yield possible on 'RobloxReplicatedStorage:WaitForChild("SetDialogInUse")'
21:47:48.321 - Script 'CoreGui.RobloxGui.CoreScripts/MainBotChatScript2', Line 71
21:47:48.322 - Stack End

Its also quite annoying for scripts I’ve made that don’t use the number parameter on WaitForChild, because I know they will exist, and it outputs the errors still.

How many scripts of yours is this happening for? How long do you expect WaitForChild to wait before your instances exist?

Probably around 30 seconds at most that I would wait.

but I use it in a few scripts.

Why can’t you update them to use the number parameter on WaitForChild in the few scripts you use it in? Waiting 30 seconds sounds like an edge case, and it’s not surprising the default behavior picks it up as not existing.

The default ( no timeout ) should be infinite, having to update every script that expects this will break a lot of places

Without a default, this update is pointless. The reason infinite WaitForChilds are an issue is because you don’t expect them to happen. “Why is this not working? Now I have to add a thousand prints to my script to figure out where it’s stopping” Planning for the unexpected is impossible.

Yielding for significant amounts of time is an edge case. You’re not going to have to update many scripts. Don’t be lazy.

It will not break a single place. It’s a warning – not an error. It doesn’t affect how your code runs.

What context are you using WaitForChild in? I’ve never gotten this error.

Mostly waiting for module scripts to load in, and other data used in the game

That’s weird. I don’t think this is a common problem. A repro will probably help the staff find the bug or help us identify the problem in the code if there is one.

I’ll try to make a simple repro for it tomorrow.

If you do not want a warning, then you need to add a timeout value. If you think it takes 30 seconds, set a 45 second timeout and handle a nil value in case it doesn’t load in time.

1 Like