Help with UserInputService

  1. What do you want to achieve?
    Testing out UserInputService.

  2. What is the issue?
    Apparently when I run the script, it says Keycode is not a valid member of InputObject "InputObject" - Client - KeybindScript:6

Here’s the script:
local UserInputService = game:GetService(“UserInputService”)

– Function –

UserInputService.InputBegan:Connect(function(Key)

if Key.Keycode == Enum.KeyCode.A then
	
	print("You pressed A!")
 end
end)
  1. What solutions have you tried so far?
    I tried finding solutions and tutorials but they don’t show how to use Keycode.

Typo error, replace it with:

if Key.KeyCode == Enum.KeyCode.A then

Do keep in mind that LUA is case-sensitive, so double-check that what you’re referencing is correct

1 Like

After weeks of not knowing why it isn’t working, you’re going to tell me it’s a typo?
Well I’m dumb

Thank you so much for pointing it out!

LOL IT’S COMPLETELY FINE

We all make mistakes, so don’t worry about it too much!

Just be sure to double-check your code & what you put inside your script is correct

2 Likes