What's an infinite yield?

Hi i’m making a simple post because I have no idea what ‘Infinite yield’ means.

I got a message saying a infinite yield was possible on something

I know it’s not the perfect place to ask the question but each time the post get deleted for not in the correct category…

Thank you everyone! Have a great day or night!

21 Likes

The warning “Infinite yield possible” actually means a thread can potentially yield infinitely.

This usually arises when you use the :WaitForChild() function, as it just waits theoretically indefinitely for an instance to be added , and when over 5 seconds have elapsed without the function returning an Instance, it returns the error.

To avoid this, specify the timeOut parameter for the function, as in :

  workspace:WaitForChild("Part",7) 
-- after 7 seconds the function will break instead of returning an error

Once the timeOut parameter has been specified, after n seconds, the function breaks and simply returns nil.


Edit : Just realized I’ve explained this before

18 Likes

“Infinite Yield possible”, Yield basically meaning stop so “Infinite stop possible” is when as mentioned above, you have a thread which can be for example the :WaitForChild() function, This thread can wait for the object specified in the parameters infinetely.

Example: You do :WaitForChild(game.Workspace.Hello) and hello does not exist in workspace, So what it will do is write out “Infinite yield possible” because it’s waiting on the object “Hello” infinetely.

4 Likes

Infinite yields are statements (kind of like waits), that last indefinitely. An example of this can be:

Instance:WaitForChild("ThisIsNonExistentSoItWillYieldInfinitely")

or simply

wait(math.huge) -- math.huge means infinity

both are infinite yields.

9 Likes

An infinite yield is when there’s something that can result in a yield which could be run infinitely(Like the people above me have said). Think about it like this. If you are waiting for a person in real life to come to you at a meeting hall or something, then there is an infinite yield possible because the person that was supposed to come might never come. Of course this is unlikely but it’s still a possibility. Similar to that, when you’re looking for something in the workspace then if you don’t set the amount of time the server should look for that object then the server will continue looking for that object forever until it finds it, hence there’s a chance that the server will be looking for it forever. Like @XxELECTROFUSIONxX a way to solve that is to just add a certain amount of time to break if the game doesn’t find the object you’re waiting for. In this analogy, the person in the meeting hall who was waiting for someone else is the server(basically the game on the unexploitable side, which the computer runs) and the person who might never come to the meeting hall is the object(maybe a part or something). Hope this helps :slight_smile:

29 Likes