PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

UserInputService.MouseBehavior1

UserInputService.MouseBehavior1

Oct 01 2018, 2:59 AM PST

The below example, when used from a /LocalScript, would cause the user’s mouse to be locked to the center of the screen. When the user attempts to move their mouse, the mouse’s delta is printed to the output.

local UserInputService = game:GetService("UserInputService")

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.InputChanged:Connect(function(inputObject)
	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		print("delta is (" .. tostring(inputObject.Delta.x) .. ", " ..  tostring(inputObject.Delta.y) .. ")")
	end
end)