Trouble getting keyboard input from user using UserInputService?
Hey, guys, I have just started to get into scripting recently and got stuck for a little while on the UserInputService where I'm trying to get the keyboard input the player presses on their keyboard. I put the local script into StarterPlayerScripts and looked at the API Reference on UserInputService and their code didn't work so I was wondering if anybody could help me out. The error message on the line where i declare the local keypressed variable and says: "KeyCode is not a valid member of InputObject" even though Object Brower has Keycode listed under InputObject. If anyone could help me out if would be a huge help. Thanks! (The following lines starting with 'userinputservice' is my code. I don't know why it doesn't have those in coding lines as well).
userinputservice = game:GetService('UserInputService')
userinputservice.InputBegan:Connect(function(input,gameProcessed)
1 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
3 | local keypressed = input.Keycode |
end)