UserInputService MouseWheel doesn't work

I’m trying to utilize the MouseWheel for one of my projects and it appears that I’m either doing it wrong, it’s being overridden by something hidden or it doesn’t work as intended entirely.

-- In a localscript under StarterPlayerScripts
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input,gameProcessed)
    if input.UserInputType == Enum.UserInputType.MouseWheel then
       print("mouse wheel")
    end
end)

I appreciate any responses. Absolutely dumbfounded by this predicament.

2 Likes

That’s because you don’t use UserInputService for this occasion, try this:

local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.WheelForward:Connect(function() -- fires when the wheel goes forwards

print("mouse wheel forward")

end)


Mouse.WheelForward:Connect(function() -- fires when the wheel goes backwards

print("mouse wheel backward")

end)
1 Like

Is there any reason as to why my code doesn’t work? It’s quite strange that there’s an enum for it but, it doesn’t fire. While the code you wrote works, I rather have mine binded under UserInputService.InputBegan for the sake of cleanliness.

Well, I found out that the mouse wheel doesn’t actually register at all in UserInputService. For clarification, if you were to have a print command after the UserInputService function, and you scrolled your mouse, there would be no output at all(maybe I’m wrong)

1 Like

Scrolling the mouse wheel fires UserInputService.InputChanged, not UserInputService.InputBegan

12 Likes

Interesting. Much appreciated.