How to track mouse wheel with UserInputService?

How do you track a player’s mouse scroll wheel? I know you can use a mouse object from Play:Get mouse(), but how could I track it with UserInputService?

1 Like

Try see if one of these helps you

https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetMouseButtonsPressed

1 Like

No, I’m looking for the mouse’s scroll wheel. I’m trying to find out how to tell when it goes forwards or backwards.

You can use the UserInputService.InputChanged event, and check the Input that it passes to see if it’s the mouse wheel. Here’s an example below:

local UIS = game:GetService("UserInputService")

UIS.InputChanged:Connect(function(Input)
    if Input.UserInputType == Enum.UserInputType.MouseWheel then -- Check if the user scrolled the mouse wheel.
        local Rotation = Input.Position.Z -- The Z property of the position indicates whether it moves forward or backwards, 1 being forward and -1 being backwards.
    end
end)

I hope this helps!

11 Likes

This is just what I needed, thanks!

2 Likes