How can I fix all of these infiniteyields?

I’m getting all of these InfiniteYields in the output that don’t normally occur in any other game I make, so how can I fix this?

I’m not sure exactly when it started happening.

Make sure that the assets you’re yielding to actually exist.
If your game uses StreamingEnabled, something like workspace.Part might not exist on the client, and so using :WaitForChild() will not work unless that part is rendered.

Infinite yield warnings occur when a :WaitForChild() call exceeds around 5 seconds. This happens either because the asset is not loading or it doesn’t exist. Make sure that the objects you are waiting for actually exist, as :WaitForChild() will continuously search for them until they are found. Additionally, it could be due to a bad internet connection, as those assets don’t always get to load within those 5 seconds.

You can add your own maximum wait time to a :WaitForChild() call, to do that you would have to do something like:

workspace:WaitForChild("Part", 0.5)

In this example, it will only wait 0.5s before giving you an error if “Part” doesn’t exist in workspace, unless of course it manages to find that part within that time range.

Make sure you search a little bit around the DevForum before posting, as there can be similar topics, such as this one:

1 Like

Thanks for taking the time to reply.

I’ve used the example code you’ve given me, and now they are gone.

1 Like

Just a quick clarification for any future readers: :WaitForChild will not error if a child with the given name doesn’t exist, it will return nil.

That being said, the below code will error:

workspace:WaitForChild("Part", 0.5).Anchored = false

If “Part” doesn’t exist after 0.5 seconds, :WaitForChild will return nil, not error; however, attempting to get the Size of nil will error.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.