Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
yellp1 193
5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by
WoolHat 53
5 years ago
Edited 5 years ago

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.

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) yellp1 193 — 5y
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. WoolHat 53 — 5y
Ad

Answer this question