I made a tool and when you equip it, it is supposed to play an animation. I did that successfully. However when you unequip it I want it to stop the animaiton. How do I do that?
my code \/
local player = game.Players.LocalPlayer local tool = script.Parent tool.Equipped:connect(function(mouse) local char = player.Character local prone = Instance.new("Animation") prone.AnimationId = "http://www.roblox.com/asset/?id=1111949983" local animloader = char.Humanoid:LoadAnimation(prone) animloader:Play() end)
don't mind the text "prone" it doesn't matter.
You could try something like this:
tool.Unequipped:connect(function() for v,i in pairs(char.Humanoid:GetPlayingAnimationTracks()) do if anim.Name == "prone" then anim:Stop() end end end)
(I honestly dont know if this will work cause i cant test it, but it would be soemthing like this)