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

Why is animation not stopping when unequipped?

This is a very simple script that is supposed to stop an animation when I unequipped a tool. T

script.Parent.Unequipped:connect(function()
	local idle = script.Parent.Parent.Humanoid:LoadAnimation (script.Idle)
	idle:Stop()
end)

It give me an error "Humanoid is not a valid member of backpack". If thats true, then why does this work?

script.Parent.Equipped:connect(function()
	local idle = script.Parent.Parent.Humanoid:LoadAnimation (script.Idle)
	idle:Play()
end)

If you can help, that would be much appreciated.

1 answer

Once the tool is unequipped , it's moved to the Backpack, so you cannot use script.Parent.Parent to get the character (which you shouldn't be doing anyways)

local plr = game:GetService("Players").LocalPlayer

script.Parent.Unequipped:connect(function()
    local idle = plr.Character.Humanoid:LoadAnimation (script.Idle)
    idle:Stop()
end)

2 comments

0

Ok. The script seems to not have an error, but the animation is not stopping now...

0

Make sure the animation isnt looped.

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