Collapse Sidebar




The EnableMouseLockOption StarterPlayer property determines if a player can toggle mouse lock by default.

Mouselock will lock the player’s cursor to the center of the screen. Moving the mouse will rotate the Camera and Player will move relative to the current rotation of the camera.

This property sets the value of Player/DevEnableMouseLock.

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