if key:byte() == "1" then
print("1 pressed")
elseif key:byte() == "2" then
print("2 pressed")
end
How come this dosent check to see if a player has pressed 1 or 2? I want it so when your player presses 1 then it prints "1 pressed"
if key:byte() == "1" then
print("1 pressed")
elseif key:byte() == "2" then
print("2 pressed")
end
How come this dosent check to see if a player has pressed 1 or 2? I want it so when your player presses 1 then it prints "1 pressed"
The number keys are reserved for the Backpack CoreGUI. I strongly suggest looking into UserInputService. With this you can check a large variety of inputs, including keyboard button presses, regardless of gamestate.
local UserInput = game:GetService('UserInputService')
UserInput.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.One then
print('1 pressed')
elseif input.KeyCode == Enum.KeyCode.Two then
print('2 pressed')
end
end)
Note: UserInputService must be used inside of a local script.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
I have removed the backpack using the Core thingy. If the backpack isnt there then can I still use your one?
UserInputService will work if it is there or not!