Tool animation script

The animation is working when I equipped the tool but if I un-equipped it it doesn’t stop.

function Equip(mouse)
	local Character = script.Parent.Parent
	local Humanoid: Humanoid = Character.Humanoid

	local AnimationTrack = Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Parent.Animation)
	AnimationTrack:Play()
end

function Unequip(mouse)
	local Character = script.Parent.Parent
	local Humanoid: Humanoid = Character.Humanoid

	local AnimationTrack = Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Parent.Animation)
	AnimationTrack:Stop()
end

Tool.Equipped:connect(Equip)
Tool.Unequipped:connect(Unequip)
1 Like

Just do that

Tool.Equipped:Connect(function()
    local idleanim = wherever it is
    local animator = humanoid.Animator
    local playAnim = animator:LoadAnimation(idleanim)
    playAnim:Play()
    Tool.Unequipped:Connect(function()
     playAnim:Stop()
  end)
end)

code may look wacky a bit since i was writing it on phone

But It’s not idle animation e.g. if you equipped the tool you will get the animation

then change it to equip animation, theres no difference or whatever animation is it

BTW so I need to put the Unequipped function inside Equiped function right?

yep, it will be easier if you do it so