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

Is there a way to check how far your mouse has scrolled?

I am making a camera script but right now I want to find a way to check how far the mouse wheel has scrolled so I can make the camera zoom out by that amount. I'm using player:GetMouse() btw

mouse.WheelForward:Connect(function(x)
	
end)

x = nil

is there another method to get the mouse or am I just stuck with the zoom distance I have right now?

1 answer

I'd recommend using UserInputService's InputChanged event to detect if the UserInputType is Enum.UserInputType.MouseWheel. From there, you can easily determine the direction from the input, which is the most important information. You can derive this from the input's Position.Z.

This is what the current CameraModule uses (Currently located under BaseCamera, breadcrumb trail starting at line 471).

Hope this helps.

2 comments

1

This answer improves my script a lot, however I still need a way to detect how far the mouse moved, not the direction. For example, some mice have a free moving scroll wheel and some get locked in certain positions. I need to find a way to detect if the mouse moved a little or if it moved a lot (the scroll wheel that is)

0

Perhaps what would better suit you in that case would be to find out how many times they scroll per second. You could do this by having a variable that's simply ScrollsPerSecond. Upon event, add one to the SPS, wait(1), then remove it. Then, you can determine what a "little" vs a "lot" is, depending on the SCP. Best I've got.

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