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

Does not read KeyDown?

Asked by 9 years ago

In a local script that I am working on there is a section that is suppose to find what key was pressed then see if it is the key that is suppose to be pressed in a textBox e.g user types in something then when he is done he clicks the outside to remove the cursor and presses "r", but it is not working. I don't get any error codes or anything.

local Player = game.Players.LocalPlayer -- for the key down events
local Mouse = Player:GetMouse()

function rButtonCheck() -- checks to see if the user pressed 'r'
    if button == "r" then
        print("player pressed return")
    end

end

Mouse.KeyDown:connect(rButtonCheck,button)

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The connect method only takes on argument, which is the function to fire (rButtonCheck in this case).


Parameters that the event pass are passed to that function when it is called. You're trying to use button here but you aren't using it as the parameter of the function:

function rButtonCheck(button)
Ad

Answer this question