I am using Roblox wiki's code for this, but ran into a quick problem and can't find it on wiki or anything. How do I use numbers for keyboard input. I tried if inputObject.KeyCode == Enum.KeyCode.1 then but I can't use numbers for keycode? I am stuck.
✓ ANSWER ACCEPTED
How to use numbers on keyboard for input?
1 answer
✓ Accepted answer
Every Enum.KeyCode is a word, not a number. To track numbers, use the words that go with them:
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.One then -- Key press detects the number 1
-- other code
elseif key.KeyCode == Enum.KeyCode.Two then -- Same here
-- some more code
end
end)
1 comment
0
oooh I understand now thank you very much, idk why i didn't think of that.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
They’re all words, meaning 1, will be One
This question is quite simple, really. Refer to https://developer.roblox.com/api-reference/enum/KeyCode . I am sure like most programming languages, the identifier mustn't start with a number.