Need help with key:byte() and key press input

I’m trying to get a keypress just for LeftCtrl so that when a player presses that key, they can toggle between run and walk. However, in doing so, the number 2 key for some reason also works (so LeftCtrl and Number 2 act at the key byte code ‘50’)

Here is the code I am using to test:

game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
    print(string.byte(key))
end)

Also, is there any way I can utilize the numpad numbers? For some reason, they aren’t working.

1 Like

Use UserInputService or ContextActionService instead.

Keys are strings, and generally cannot be converted to single characters so calling string.byte on a Key or Key.Name doesn’t really make sense. Just compare key.KeyCode to any of the available ones, which includes KeyPad keys and both left and right Control, Alt, etc.

1 Like