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.
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)