Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you stop an animation in a tool?

Asked by 7 years ago
Edited 7 years ago

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.

0
The command is either :Stop() or :Pause() or something like that, Viking359 161 — 7y

1 answer

Log in to vote
0
Answered by
Nikkulaos 229 Moderation Voter
7 years ago

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)

0
That didn't work :( Notpace 2 — 7y
Ad

Answer this question