Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I lock the player's mouse?

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

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.

1 comment

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.