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 \/
1 | local player = game.Players.LocalPlayer |
2 | local tool = script.Parent |
3 | tool.Equipped:connect( function (mouse) |
4 | local char = player.Character |
5 | local prone = Instance.new( "Animation" ) |
6 | prone.AnimationId = "http://www.roblox.com/asset/?id=1111949983" |
7 | local animloader = char.Humanoid:LoadAnimation(prone) |
8 | animloader:Play() |
9 | 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)