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

Infinite yield possible? What does it mean?

Hiya! I'm having some trouble with a script...it's a problem I've encountered in the past but I was never able to figure it out. Take a look:

local enable = true
local player = game.Players.LocalPlayer
local anime = script:WaitForChild('Animation')
script.Parent.MouseButton1Click:connect(function()
	if enable == true then
		enable = false
		local animationTrack = player.Character.Humanoid:LoadAnimation(anime) -- doesn't work
		wait(2)
		enable = true
	end
end)

I'm not sure what is wrong... and here's what the output is telling me:

20:02:33.440 - Infinite yield possible on 'Players.Lukeisbossman64.PlayerGui.list.scrolly.wave.LocalScript:WaitForChild("Animation")'
20:02:33.442 - Stack Begin
20:02:33.443 - Script 'Players.Lukeisbossman64.PlayerGui.list.scrolly.wave.LocalScript', Line 3
20:02:33.443 - Stack End

I tried taking the WaitForChild thing out in the 3rd line on the script, but the output said that it couldn't find it as a child(not enough time to load.) So... this has left me confused. Any Help?

4 comments

0

It means that there is an infinite yield possible.

1

Wow! So helpful! My script works now. NOT

0

Make sure it is named correctly, spelt correctly and all capital letters done correctly.

0

also what you are doing is looking for children of the script, not the parent if the script

2 answers

Ref<Instance> WaitForChild (
    string childName,
    double timeOut
)

Since you haven't specified a timeout, the current thread yields (think "the script halts") until the child is found. If the child is never found, then the script can never run; this would interfere with roblox's scheduler, in all likelihood.

Infinite yield = Stopped forever

http://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild

3 comments

0

Can you please tell me how to fix it?

0

I don't get how to make a a timeout or whatever.

0

Instance:WaitForChild(child, timeout). Child is the name of the object, and timeout is any number greater than or equal to 0 in seconds (the number of seconds that the function is allowed to wait).

Description: An infinite yield possible means that you are using WaitForChild() and it is possible that it will take forever to Find the item

Example:

local brick = nil
workspace:WaitForChild(brick)

Because the brick is false and not there, it will say infinite yield possible...

How to fix: To fix this you may wanna try finding WaitForChild() in your code and you may want to alter what is in the parenthesis... To make sure it doesn't say "Infinite yield......" fix the anime variable

I hope this helped, bye

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