Ad
Log in to vote
0

How do I lock the player's mouse?

Asked by
XDvvvDX 186
9 months ago

Hello. I've seen many games locking the player's mouse, but I don't know how. Like they enable shift lock to the player without him pressing left shift. I would absolutely accept the helpful answer!

1 answer

Log in to vote
1
Answered by 9 months ago
Edited 9 months ago

https://developer.roblox.com/en-us/api-reference/property/UserInputService/MouseBehavior

local UserInputService = game:GetService("UserInputService")

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition -- or LockCenter or Default

Default: The mouse moves freely around the user’s screen.

LockCenter: The mouse is locked, and cannot move from, the center of the user’s screen.

LockCurrentPosition: The mouse is locked, and cannot move from, it’s current position on the user’s screen at the time of locking.

0
Hello. I appreciate your help, but I meant to shift-lock, how to enable shift lock without the player pressing Left Shift. Thanks anyways! XDvvvDX 186 — 9mo
Ad

Answer this question