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

How do you stop an animation in a tool?

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.

1 comment

0

The command is either :Stop() or :Pause() or something like that,

1 answer

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)

1 comment

0

That didn't work :(

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