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

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

Asked by 5 years ago

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

Log in to vote
1
Answered by 5 years ago
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.

Ad

Answer this question