:GetMouseDelta() returning absurdly high values even though mouse not moving

I’ve never had a problem with getMouseDelta until today when all of a sudden its started returning absurdly high values.
I set my cameraMode to LockFirstPerson and MouseBehavior to LockCenter.
When my character first spawns (custom spawn, playerautoloads set to false), and I right click for the first time without moving my mouse I get absurdly high values even though my mouse is not moving.
My output:

19:18:59.744 - 0 0 (x106)
19:19:03.962 - 945 430 (x231)

where the first value is the deltaX and the second value is the deltaY.
This is literally the only part of my code you need to be concerned about:

local delta = uis:GetMouseDelta()
print(delta.X, delta.Y)

Now theres absolutely no way I managed to somehow move my mouse precisely 945 delta on the x axis and 430 delta on the y axis consistently for 231 frames or approx 3.85 seconds.
This isn’t a problem with my mouse, this only ever occurs in studio, and does not occur in game, and I have absolutely no clue as to why.
Only seems to stop returning the high values after moving the mouse or stopping right clicking.

1 Like

This belongs in Studio bugs, as I’d love to help you fix this, we can’t fix studio exclusive bugs.

Posted a studio bug report

1 Like

I don’t know that this is a bug so much as it is you trying to read a delta before any inputs (mouse movements) have been recorded.

I would do this:

local delta = Vector3.new()

game:GetService("UserInputService").InputChanged:Connect(function(input, gp)
    if not gp and input.UserInputType = Enum.UserInputType.MouseMovement then
        delta = input.Delta
    end
end)

And then use delta wherever you need it in the rest of the script.

2 Likes

I was previously using this method, however I did’t like how it looked, but since it looks like I may be forced to use it, I’ll have to re implement it.
Disappointed nonetheless, but atleast theres a solution ,even if its not the nicest looking :stuck_out_tongue:

You just gotta change your mindset :slight_smile:

Event-based updates for event-based changes is the more elegant way to go, IMO.

1 Like