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

What is Infinite Yield Possible and How to fix it?

Asked by 4 years ago

Im new to this and I found a crawl script and the output says: Infinite yield possible on 'ServerScriptService.CrawlServer:WaitForChild("CrawlMove")' How can I fix this?

local rStorage = game:GetService("ReplicatedStorage") local rEvents = rStorage:WaitForChild("RemoteEvents")

game.Players.PlayerAdded:Connect(function(plr) local crawlValue = Instance.new("BoolValue",plr) crawlValue.Value = false crawlValue.Name = "CrawlEnabled"

local char = workspace:WaitForChild(plr.Name)
local human = char:WaitForChild("Humanoid")

local idleLoaded = human:LoadAnimation(script:WaitForChild("CrawlIdle"))
local moveLoaded = human:LoadAnimation(script:WaitForChild("CrawlMove"))

human.Running:Connect(function(speed)
    if speed > 0 and crawlValue.Value == true then
        moveLoaded:Play()
    else
        moveLoaded:Stop()
    end
end)

crawlValue:GetPropertyChangedSignal("Value"):Connect(function()
    if crawlValue.Value == true then
        human.WalkSpeed = 8

        idleLoaded:Play()
    else
        human.WalkSpeed = 16

        idleLoaded:Stop()
        moveLoaded:Stop()
    end
end)

end)

rEvents.CrawlEvent.OnServerEvent:Connect(function(plr,enabled) local crawlValue = plr:WaitForChild("CrawlEnabled")

crawlValue.Value = enabled

end)

1
An infinite yield denotes that the child it's searching for was not found and has taken an unreasonable amount of time to locate; the Script will warn you of a potential scenario where it may hang forever. Check the Instance Name if it is a child of the Script, and make sure there aren't any accidental trailing whitespace characters Ziffixture 6913 — 4y
0
please accept his answer so it isnt on the front page anymore Code1400 75 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Starting off, :WaitForChild() yields or waits until the object is loaded in or render. Infinite yield just means that the script might yield or wait forever, but it usually doesn't unless you typed the name of the instance wrong. The infinite yield warning is mostly common on LocalScript's as they load before the server, especially scripts inside ReplicatedFirst.

0
Thanks for the reply, do you know what i have to change in my script to fix it? citkat1250 5 — 4y
0
Perhaps put the animations somewhere else such as ServerStorage? youtubemasterWOW 2741 — 4y
0
thanks but it gave me the same message, if youre free i could invite you as a team dev and you could help me out? thanks for helping though :) citkat1250 5 — 4y
0
Okay, I guess I am quite free so I could help you out. youtubemasterWOW 2741 — 4y
View all comments (4 more)
0
Thanks a ton, i'll message you soon citkat1250 5 — 4y
0
Okay. youtubemasterWOW 2741 — 4y
0
Ok, sent a friend request citkat1250 5 — 4y
0
I've accepted it. youtubemasterWOW 2741 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

infinite yield is when :WaitForChild() is not finding an object which causes the script to stop at that spot and wouldn't go on, you might as well define the animations (if you created them in the workspace and not the script) using :FindFirstChild() like this...

local crawlIdle = script:FindFirstChild("CrawlIdle")
local crawlMove = script:FindFirstChild("CrawlMove")
local clawlIdleAnim -- Leaving this nil so that the animation wouldn't be local inside the if
local crawlMove
if crawlIdle then
    crawlIdleAnim = human:LoadAnimation(crawlIdle)
    crawlMoveAnim = human:LoadAnimation(crawlMove)
end

Answer this question