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.
01 | local humanoid = [ Wherever Humanoid Is ] |
02 | local animationTrack = humanoid:LoadAnimation( [ Wherever The Animation Is ] ) --Sets up AnimationTrack |
03 |
04 | local playingAnimation = false |
05 | [ Wherever The Textbutton Is ] .MouseButton 1 Click:Connect( function () |
06 | if playingAnimation = = true then |
07 | playingAnimation = false |
08 | animationTrack:Stop() |
09 | elseif playingAnimation = = false then |
10 | playingAnimation = true |
11 | animationTrack:Play() |
12 | end |
13 | 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.