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

How to make the animation stop running?

Asked by
yeez_d 0
3 years ago

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! :)

0
dance:Pause()? onforgot 11 — 3y
0
dance:Pause() bud lo_1003 42 — 3y

Answer this question