Cannot get the delta of the mouse. Help!

  1. What do you want to achieve? Keep it simple and clear!
    I want to get the delta of the mouse.

  2. What is the issue? Include screenshots / videos if possible!
    I have tried several ways of doing it such as the ones I have provided below, and none of them actually return anything other than a Vector3 (0,0,0)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried things like

UserInputService:GetMouseDelta()

and

local userInputService = game:GetService("UserInputService")

userInputService.InputChanged:Connect(function(io)
	userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	if io.UserInputType == Enum.UserInputType.MouseMovement then
		print(io.Delta)
	end
end

Yet none of them work. I have tried this both in studio and in the roblox app and it is broken in both places. It just prints out a Vector3 with (0,0,0). I have also tried moving the location of the local script. I’ve also made sure that the mouse is locked.
It could be a stupid problem that I just missed, but any help is appreciated!

UserInputService only gives the Delta when the camera moves. Set “CameraMode” in StarterPlayer to “LockedFirstPerson” and move your mouse to get different values for your .InputChanged script.

You need to lock the mouse to the center on each frame, try this:

local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")

runService.RenderStepped:Connect(function()
	userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	local delta = userInputService:GetMouseDelta()
	print(delta)
end)

These examples above are just samples of code that is in a RenderStepped event function. They are taken out of the code and just written out again differently. I should have specified. Locking the mouse in the center every render frame is already done.

Nevermind! It was something stupid that was unrelated to this bit of code.
Sorry!

Okay but what was it? I’m having the same problem and it could be helpful to know your solution.