Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Infinite yield possible? What does it mean?

Asked by 6 years ago

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?

0
It means that there is an infinite yield possible. hiimgoodpack 2009 — 6y
1
Wow! So helpful! My script works now. NOT Lukeisbossman64 73 — 6y
0
Make sure it is named correctly, spelt correctly and all capital letters done correctly. abnotaddable 920 — 6y
0
also what you are doing is looking for children of the script, not the parent if the script abnotaddable 920 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
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

0
Can you please tell me how to fix it? Lukeisbossman64 73 — 6y
0
I don't get how to make a a timeout or whatever. Lukeisbossman64 73 — 6y
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). KidTech101 376 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

Answer this question