Infinite Yield on something already loaded

So essentially, there’s a chance that an infinite yield will happen on a part named “Hitbox”. (This infinite yield happens some of the time, but not all of the time)
image
(This is also someone else’s screenshot of the dev console in my game)
However, if i print out all of the descendants of the parent, I can see that the instance does in fact exist.
image

BOTH of the infinite yield and the code that prints out the descendants are client sided.

I know there is similar topics on the devforum, but those are because the server has the instance loaded but the client doesn’t, but this is different.

Not sure if it helps, but Hitbox is a child of the custom starter character. This also is something that only sometimes errors.

At the moment, I’ve got no idea why this happens. However, I do know that WaitForChild has a timeout parameter. If you don’t want this warning to appear, add a number as a second argument to the method call, like NinjaBoss11:WaitForChild("Hitbox", 5). The line I just provided will make the method skip if 5 seconds pass and it can’t find Hitbox.

Have you ever had this problem before?

No, but 15 seconds of testing shows me that this does get rid of the warning. If you want to mention what exactly is “error[ing]”, I think I’d be able to provide a more robust solution. Knowing what the code looks like would help too, since I think this should be caused by a race condition.

Is workspace Streaming Enabled on? That can cause issues.

findfirstchild or waitforchild

local x= obj:FindFirstChild("itemName") or obj:WaitForChild("itemName")

this should prevent infinite yield from happening
@SnoogleBrosPlayz

Does this warning happen before you output all of the parts? If yes, then it should be all good.

WaitForChild has no timeout limit, but after 5 seconds of yielding, it will throw that warning (hence “infinite yield possible”). This means that it can search for 5+ seconds and find the instance, then continue as normal. All the warning means in this context is WaitForChild yielded for at least 5 seconds, so it’s letting you know you might have forgotten to create an instance. Since this only happens sometimes, it sounds like this is the problem because some devices may take longer to load than others.

No the warning happens AFTER I output all the parts, which is the reason I made this because it confused me

Also I know I can put in the second parameter for WaitForChild to prevent infinite yields, but I can’t have the script skip the part because the part is pretty important.