Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I lock the player's mouse?

Asked by
XDvvvDX 186
3 years 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
LeHelary 142
3 years ago
Edited 3 years 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 — 3y
Ad

Answer this question