I'm currently new to scripting, so I apologize for my simple mistakes.
I'm making a GUI where you have to click one of the text buttons and an Animation will work. I made the animation work through the MouseButton1Click, but now I'm trying to make it so that once you click the text button again, it will stop.
local btn = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid",10)
local CanEmote = true
local Cooldown = 1
btn.MouseButton1Click:Connect(function()
if CanEmote == true then
Humanoid.JumpPower = 0
Humanoid.WalkSpeed = 0
CanEmote = false
local dance = Humanoid:LoadAnimation(script:FindFirstChild("Anim1"))
dance:Play()
wait(Cooldown + dance.Length)
Humanoid.JumpPower = 50
Humanoid.WalkSpeed = 16
CanEmote = true
end
end)
Thank you in advance! :)

2 comments
dance:Pause()?
dance:Pause() bud