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

Everytime i move they code prints, but the key is q..any help?

Asked by
Jirozu 71
8 years ago
Edited 8 years ago
01Player = game.Players.LocalPlayer
02Mouse = Player:GetMouse()
03Combo = 0
04 
05 
06Mouse.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
View all 28 lines...
1
More explination to what the code issue is rather than the code itself? GreekGodOfMLG 244 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

01Player = game.Players.LocalPlayer
02Mouse = Player:GetMouse()
03Combo = 0
04 
05 
06Mouse.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)
View all 29 lines...
Ad

Answer this question