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

Infinite Yield Possible on my Animation script?

I've been trying to make an animation that is used when you hold the tool, but it doesn't seem to be working. The error I get says

Infinite yield possible on 'ReplicatedFirst.IfHolding:WaitForChild("Animation")'

My Script:

local animation = script:WaitForChild('Animation')
local humanoid = script.Parent:WaitForChild('Humanoid')
local dance = humanoid:LoadAnimation(animation)
Tool = game.StarterPack.Pitchfork

Tool.Equipped:Connect(function()
dance:Play()
end)
Tool.Unequipped:Connect(function()
dance:Stop()
end)

This script worked on another game I made but instead, I used it on an NPC, this time, I want to use it on the actual player itself. Thanks

1 answer

✓ Accepted answer

"Animation" is not a valid member of script (There is no child named Animation). Try creating a new animation in the script.

local IDGOESHERE = 111 -- put your id here


local id = tostring(IDGOESHERE)
local animation = Instance.new("Animation",script)
animation.AnimationId = "rbxassetid://"..id
local humanoid = script.Parent:WaitForChild('Humanoid')
local dance = humanoid:LoadAnimation(animation)
Tool = game.StarterPack.Pitchfork

Tool.Equipped:Connect(function()
dance:Play()
end)
Tool.Unequipped:Connect(function()
dance:Stop()
end)

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