Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Detecting the direction the mouse wheel is moving?

I can detect when the wheel is being used by using UserInputService, like so:

uis.InputChanged:connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		print("WHEEL")
	end
end)

The problem is that I cannot get the direction (forward or backward) that the mouse wheel is moving.

I have even tried using a ScrollingFrame with the MouseWheelForward and MouseWheelBackward events to detect when either of those things happen, but those events don't seem to fire.

Is there any other way I can detect the direction the mouse wheel is scrolling?

1 answer

✓ Accepted answer

You're on the right track actually! You need to check the sign of the Z component in the Position property of the inputobject!

uis.InputChanged:connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseWheel then
        print("WHEEL GOING " .. input.Position.Z > 0 and "UP" or "DOWN")
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.