UserInputService test not working

So I placed the script inside Starter Player > StarterCharacterScripts and when I pressed play to test my script nothing seemed to be printing.

local uis = game.GetService (“UserInputService”)
uis.InputBegan:connect (function(input,gpe)
if input.Keycode == Enum.KeyCode.H then
print (“Test”)

end

end)

the “.” Should be “:”

Capitalize the first letter of connect.

1 Like

Did you use a local script or a script?
deaba354a59cac447e4fc649dbd3a68a

I used a script on startercharacterscripts

Use a local script instead server scripts don’t work for client functions

Now it says here " Keycode is not a valid member of InputObject “InputObject” - Client - LocalScript:3"

local uis = game:GetService(“UserInputService”)
uis.InputBegan:Connect(function(input,gpe)
if input.Keycode == Enum.KeyCode.H and not gpe then
print (“Test”)

end

end)

try thsi

Make the First KeyCode(input.Keycode) Input.KeyCode

Which would then look like this(in your code):

local uis = game:GetService("UserInputService")
--Added a space for better readability | Also indented
uis.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.H then
		print("Test")
	end
end)

Now it says here " Keycode is not a valid member of InputObject “InputObject” - Client - LocalScript:3"

OHHH! rename input.Keycode to input.KeyCode

But aren’t those the same? Or am I just that bad at scripting…

its the same but things are case sensitive(meaning that it has to be spelled exactly right)

If I am correct thats what I said?

Yes they are the same name but its case sensitive. So its understands what KeyCode means but not Keycode.

Also the script I provided fixes that error, so make sure you actually updated it.