Enum.KeyCode not working correctly?

Hello,

I have an InputBegan for number keys, as in 1,2,3, etc.(Note, not keypad) The letter keys function as normally, however, the number keys do not output anything, and I have no errors or any information why. I also have the default backpack disabled currently.

Code:

local usi = game:GetService("UserInputService")

usi.InputBegan:Connect(function(io, p)
    if io.KeyCode == Enum.KeyCode.One then
	--tM.numberSlot1() function trying to be passed
	print('1')
	end
end)

If someone could guide me, I would appreciate all and any help I receive.

4 Likes

I ran your code in a LocalScript in the PlayerGui and it worked as expected. Have you made sure your script is running (in PlayerGui, PlayerScripts, Backpack, ReplicatedFirst, or the character and is not disabled) and the InputBegan is being connected before triggering the button?

4 Likes

The LocalScript is currently placed in StarterPlayerScripts. My keys 1-4 are for some reason not working, but 5-9 are.(not a keyboard problem) Let me check if I have it being occupied by anything else at the moment.

Although, I do have a custom character being placed into the character, maybe If I try putting an:

if character then...

I’ll get back to you.

Still nothing, I still have no clue why. I read through every script I had, even irrelevant ones. I may just need may to make a separate script attached to an event.

Never-mind any of that, I forgot my keybinds in studio are 1,2,3,4 for select, move, scale, and rotate. Changing those now, thanks for help regardless.