Infinite Yield on Tool UI

Hello there,

I’ve been having this problem with my tool for a while. I keep getting this error saying "Infinite Yield on ParryEnduranceUI:WaitForChild(“Val”). Does anyone know what that means and how to fix it?

Error

image

Code

2 Likes

Instance:WaitForChild(name, timeout), if you don’t supply the timeout it can yield forever; and Roblox will warn you if it doesn’t return in 5 seconds. If you supplied a timeout, if the time you supplied has passed it will just return nil.

Options to fix it:

  • “Fix it” by supplying math.huge (it won’t show a warning), could still yield forever.
  • Give a timeout if you actually don’t know it will exist, and handle the possible nil accordingly
  • Check the name, make sure the instance will actually exist.

An actual, possible error: You rename an object to “Val”, WaitForChild doesn’t listen for name changes.

I would assume the 3rd option is the one you’d want.

2 Likes

Val is the correct name.

How would I add a timeout?

It would be :WaitForChild(“Val”, 5), for example. But since the instance exists, you may or may not want it. Instead, try doing something like wait(5) and then print all the children, see what exists. It could come down to how you’re taking the UI from under the script.

Also I just noticed the screenshot has the script parented under a ServerScript, that’s not good practice.

2 Likes

Yeah its inside a localscript.

Is it fine that way or should I put it somewhere like in the ReplicatedStorage

It can depend on the case but the LocalScript should probably be in a Starter_ container.

1 Like