01 | Player = game.Players.LocalPlayer |
02 | Mouse = Player:GetMouse() |
03 | Combo = 0 |
04 |
05 |
06 | Mouse.KeyDown:connect( function (key) |
07 | key = key:lower() |
08 | if key = = "q" and Combo = = 0 then |
09 | wait(. 2 ) |
10 | Combo = 1 |
11 | print ( "PunchRight" ) |
12 |
13 | elseif Combo = = 1 then |
14 | wait(. 2 ) |
15 | Combo = 2 |
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.
01 | Player = game.Players.LocalPlayer |
02 | Mouse = Player:GetMouse() |
03 | Combo = 0 |
04 |
05 |
06 | Mouse.KeyDown:connect( function (key) |
07 | key = key:lower() |
08 | if key ~ = "q" then return end ; -- Escape if q was not pressed. |
09 | if Combo = = 0 then |
10 | wait(. 2 ) |
11 | Combo = 1 |
12 | print ( "PunchRight" ) |
13 |
14 | elseif Combo = = 1 then |
15 | wait(. 2 ) |