User Input Service not detecting RMB

Hi! I was making an ability for a weapon and i wanted it to fire when i clicked RMB. However UserInputService is not detecting any of my mouse inputs.

Heres my code:

UserInputService.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.MouseRightButton then --This is where the error is happening
		if GPE == false and abilityDebounce == false then
			if weapon.Parent == character then
--Ability code
			end
		end
	end
end)

Is there anyone else facing this issue?
How can i fix this?

if input.UserInputType == Enum.UserInputType.MouseButton2 then
1 Like

nvm i got this to work properly. thanks!

The buttons of a mouse are disconnected from the keyboard; you’re using the wrong component of the InputObject provided to you by UserInputService.InputBegan. Make sure to use “UserInputType”

oh right got it! i thought the keyboard way would work mb. thanks again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.