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

How to stop my animation from playing by clicking on it again to stop??

Alright, so when I press the textbutton the animation start playing, but when I press it again it doesn't stop? How do I stop it? I want the system to be like in the clubs on ROBLOX.

1 answer

local humanoid = [Wherever Humanoid Is]
local animationTrack = humanoid:LoadAnimation([Wherever The Animation Is])--Sets up AnimationTrack

local playingAnimation = false
[Wherever The Textbutton Is].MouseButton1Click:Connect(function()
	if playingAnimation == true then
		playingAnimation = false
		animationTrack:Stop()
	elseif playingAnimation == false then
		playingAnimation = true
		animationTrack:Play()
	end
end)

This should work, it basically uses a boolvalue to store if it should be playing or stopping the animation.

If you want to learn more about AnimationTracks then go here.

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