Why won't userinputservice work?

Hey, UserInputService won’t work.

Local script:

uis.InputBegan:Connect(function(key, gameProcessed)
	if (not gameProcessed) then
		if key == Enum.KeyCode.R then
			script.Parent.reloadGun:FireServer()
		end
	end
end)

you forgot to type in .KeyCode:

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key, gameProcessed)
	if (not gameProcessed) then
		if key.KeyCode == Enum.KeyCode.R then
			script.Parent.reloadGun:FireServer()
		end
	end
end)
1 Like
if key.Keycode == Enum.KeyCode.R