How to move the mouse / camera while mouse is locked

I locked the mouse using UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

Now I want that when the player moves the mouse the character / camera will follow the mouse but this is happening :

robloxapp-20200323-1744417.wmv (2,2 MB)

The mouse is jumping back

I think its because of this lines :

local function camUpdate()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	cam.CFrame = CFrame.new(Torso.WeaponCam.WorldPosition,Vector3.new(x,y,face.Z*9999))
end
UserInputService.InputChanged:connect(function(move)
	if move.UserInputType == Enum.UserInputType.MouseMovement then
		local rotation = UserInputService:GetMouseDelta()
		x = rotation.x
		y = rotation.y
		camUpdate()
	end
end)

Im trying to make that for 5 hours now pls help

What does camUpdate() do in your script? On a second note, it might be because of this:

x = rotation.x
y = rotation.y

When you stop moving your mouse, x and y become zero, and the camera locks back to the center.

1 Like

ye I noticed that and thats what im asking :c

But I found a fix by myself

1 Like

Could you share the fix so other people don’t suffer from a similar issue?

3 Likes