How do I detect mouse speed?

-What do I want to achieve?- Basically: get how much the mouse position changed to set a mouse speed counter, just detect how fast the player is moving the mouse on the screen.
-What solutions have I tried so far?- I tried some sistems but the dont really make much sense, I dont know how to do it.
Thanks a lot to Dan_foodz for solving the problem!!
I also have a basic scripting level, that´s probably why I didn´t found a correct way to do it :sweat_smile:

3 Likes

What would mouse speed be even measured in? I don’t think there’s such a thing.

I think taking the difference between two mouse positions (original vs new) and dividing by an arbitrary amount of time measured would be the best way of doing this.

For simplicity you could use something like this as well:

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

local LastPosition = Vector2.new(0,0)

local TextLabel = script.Parent.TextLabel

while wait(0.1) do
	TextLabel.Text = math.floor((Vector2.new(Mouse.X, Mouse.Y) - LastPosition).Magnitude + 0.5)..' Pixels Per 1/10 Sec'
	LastPosition = Vector2.new(Mouse.X, Mouse.Y)
end

I made this, and it works very well.

4 Likes

Is REALLY GOOD!!
Thank you!! Is just what I need!

Cursor speed is measured in Dots per Inch (DPI)