Collapse Sidebar




This property determines if a player is able to toggle Mouse|mouse lock by pressing Shift. A player can disable the mouse lock switch in Roblox’s game settings. By default, this property is set to the value of StarterPlayer/EnableMouseLockOption. This can be set server-side during run-time by using a Script. It can not be set client-side.

What is Mouse Lock?

When mouse lock is enabled, the player’s cursor is locked to the center of the screen. Moving the mouse will orbit the camera around the player’s Player/Character|character, and character will face the same direction as the Camera|camera. It also offsets the camera view just over the right shoulder of the player’s character.

Below, the camera is moved left and right first by holding right-click. Then, mouse lock is enabled which changes the mouse to a target reticule, and offsets the camera. The camera is again moved left and right (without holding right click).

Code Samples

Toggling Mouse Lock Ability

This code sample demonstrates how to toggle whether mouse lock is available to a player using a chat command. When a player types “mouselock”, their ability to toggle mouse lock is toggled. Note that this does not toggle the actual state of mouse lock; rather, it changes whether a player is able to toggle it themselves.

This code can be run by pasting it into a Script within ServerScriptService.