Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Output says "Infinite Yield possible' what did i do wrong?

So im and referencing stuff for my custom chat and i have these variables

local Chat = script.Parent:WaitForChild("Chat")
local list = Chat:WaitForChild("List")

Everything is named correctly i am sure of it but when i take of wait for child like this

local Chat = script.Parent:WaitForChild("Chat")
local list = Chat.List

The output then says there is nothing called List in the Chat

It works in studio sometimes printing the infinite yield thing but it works most times yet on roblox it never works and outputs an error.

2 answers

✓ Accepted answer

That means the thing you are waiting for isn't there and meaning it's possible it will be waiting for infinitley.

3 comments

0

But it is there and it stops the script from running idk if there is any way to pcall it but everything is there once again

0

play the game and look in your explorer if your item your trying to wait for is there

0

NVM I just started a new project

According to the roblox api reference manual, Infinite Yield Possible warning happens when:

a call to this function exceeds 5 seconds without returning, and no timeOut parameter has been specified, a warning will be printed to the output that the thread may yield indefinitely; this warning takes the form Infinite yield possible on X:WaitForChild("Y") , where X is the parent name and Y is the child object name.

so to stop it from giving this warning and wait forever, add a timeOut parameter, like this:

X:WaitForChild("Y",100) -- 100 is the timeOut parameter. with this, the waitforchild function will be capped at 100 seconds instead of inf seconds (without the timeout parameter).

More abt the waitforchild function

This discussion is preserved as it was. New answers, comments, and votes are closed.