Player = game.Players.LocalPlayer Mouse = Player:GetMouse() Combo = 0 Mouse.KeyDown:connect(function(key) key = key:lower() if key == "q" and Combo == 0 then wait(.2) Combo = 1 print("PunchRight") elseif Combo == 1 then wait(.2) Combo = 2 print("PunchLeft") elseif Combo == 2 then wait(.2) Combo = 3 print("RightKick") elseif Combo == 3 then wait(.2) Combo = 0 print("LeftKick") end end)
A programmer goes to the grocery store...
In your elseif
conditions, you fail to check whether the key is q
still. As a result, they will check regardless of whether q
was pressed at all. A simple solution is to escape at the top.
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() Combo = 0 Mouse.KeyDown:connect(function(key) key = key:lower() if key ~= "q" then return end; -- Escape if q was not pressed. if Combo == 0 then wait(.2) Combo = 1 print("PunchRight") elseif Combo == 1 then wait(.2) Combo = 2 print("PunchLeft") elseif Combo == 2 then wait(.2) Combo = 3 print("RightKick") elseif Combo == 3 then wait(.2) Combo = 0 print("LeftKick") end end)