Why is UIS.InputBegan not working?

So I am trying to make a keybind for a crowbar weapon. Only problem is that the UserInputService is just not firing? I tried everything! It has no errors in the output and does not print “TEST”.

Script:

local UIS = game:GetService("UserInputService")

local CrowbarEquipped = false
local EquipDebounce = false

UIS.InputBegan:Connect(function(Key)
	if Key == Enum.KeyCode.Q and CrowbarEquipped == false and EquipDebounce == false then
		print("TEST")
	end
end)

Can someone please help me? I have tried to figure this out for about an hour now. :I

Try this:

local UIS = game:GetService("UserInputService")

local CrowbarEquipped = false
local EquipDebounce = false

UIS.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Q and CrowbarEquipped == false and EquipDebounce == false then
		print("TEST")
	end
end)
1 Like

Oh my god I just noticed that mistake… I feel like I am blind sometimes. TYSM!

No problem! And don’t worry, everyone make mistakes. Actually very often small invisible things cause scripts to fail. It happens to me a lot too.

1 Like