0

My punching Animation Won't stop as once I press M1(LeftClick) it just keeps on punching and won't stop so I'm trying to get the animation to only play when I punch once and than once I press it once it stops and if I press it again it will play the second animation which is the right punch animation and stop

local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local count = 0
local debounce = false

UIS.InputBegan:Connect(function(Input, IS)
    if IS == true then return end
    if debounce == true then return end

    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
        if count == 0 then
            spawn(function()
               wait(0.1)
               count = count + 1
            end)

            game.ReplicatedStorage.CombatHit:FireServer()
            local animation = plr.Character.Humanoid:LoadAnimation(script.LeftPunch)
            animation:Play()
            print("Left Click")
        end

        if count == 1 then
            count = 0
           if debounce == true then return end
            debounce = true
            game.ReplicatedStorage.CombatHit:FireServer()
            local animation = plr.Character.Humanoid:LoadAnimation(script.RightPunch)
            animation:Play()
           print("Left Click")
            wait(1)
           debounce = false
        end
    end
end)
2
  • RightPunch's loop flag is off, right? Great title btw
    – Andrew Yim
    Commented Jun 27 at 20:47
  • Yes the RightPunch loop flag is off Commented Jun 27 at 22:47

0