Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong in my roblox code in the UserInputService ?

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
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

Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question