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

Help with KeyUp event?

Asked by 9 years ago

For some reason when I press the Q key it does line 7 but not line 5,why and how do I fix it?

game.Players.PlayerAdded:connect(function(Player)
        PlayerMouse = Player:GetMouse()
    PlayerMouse.KeyDown:connect(function(Key)
        if Key == q then
            print(Key,"has been pressed")
        else
            print(Key,"is the wrong key")
        end
    end)
end)

1 answer

Log in to vote
3
Answered by 9 years ago

You forgot to put the 'q' into quotes (This is a quote: ");

game.Players.PlayerAdded:connect(function(Player)
repeat wait(0)until Player:GetMouse() --I like to use this to wait until the script gets the Player's Mouse before going on
PlayerMouse = Player:GetMouse()
PlayerMouse.KeyDown:connect(function(Key)
if Key == "q" then --Here we go, you Silly Billy :)
print(Key,"has been pressed")
else
print(Key,"is the wrong key")
end
end)
end)

Hope this helped!

0
My bad :3 kevinnight45 550 — 9y
Ad

Answer this question