We use cookies on this site to enhance your user experience
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

Enabling a Player's Mouse Lock

The example demonstrates how to enable and disabled whether a player can lock their mouse.

In this example, we set the use a while true loop to toggle the state of the DevEnabledMouseLock property between true and false every 5 seconds. While this example has little practical use, it demos how to change the property via a LocalScript.

local player = game.Players.LocalPlayer

while true do
	player.DevEnableMouseLock = not player.DevEnableMouseLock