Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is wrong in my roblox code in the UserInputService ?

UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProccesedEvent) if input.Keycode == Enum.KeyCode.A then print("Player pressed the A key") end end)

The error: 15:26:01.142 Keycode is not a valid member of InputObject "InputObject" - Client - LocalScript:4 15:26:01.143 Stack Begin - Studio 15:26:01.145 Script 'Players.carrotboardgame.PlayerScripts.LocalScript', Line 4 - Studio - LocalScript:4

15:26:01.145 Stack End - Studio

2 answers

✓ Accepted answer
UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProccesedEvent) if input.KeyCode == Enum.KeyCode.A then print("Player pressed the A key") end end)

As Shounak said, I changed it for you

The problem is that you said input.Keycode instead of input.KeyCode. What I'm saying is that the "c" should be upper case letter - C. If you fix that your script will be working fine

This discussion is preserved as it was. New answers, comments, and votes are closed.