Question: Is there a way to force shift lock in a script?

Yes, Go to StarterPlayer and there should be an option called EnableMouseLock.

1 Like

It does not force it i want it to be forced


Starter player was located on explorer.

The settings is the properties window.

If you din’t see explorer, follow my steps :

  • go to view

  • explorer

  • properties

Make sure the Explorer and Properties are open for starter player

It’s not truly imposible to do that.

1 Like

Try restarting studio or playtest.

1 Like

LocalScript within the player:

game:GetService"UserInputService".MouseBehavior = Enum.MouseBehavior.LockCenter

For further reference, check out the UIS docs

1 Like

Try putting this in workspace : script.

Game : GetService"Starter Player".EnableMouseLockOption = true

Putting in Starter Player uses a Local Script

Do my script works?
Yes, it’s 100% a working script

1 Like

Wait so it goes in starter player scripts?

1 Like

Yes. If you want a toggleable system, you can do this

eventHere:Connect(function() --Enable
game:GetService"UserInputService".MouseBehavior = Enum.MouseBehavior.LockCenter

eventHere:Connect(function() --Disable
game:GetService"UserInputService".MouseBehavior = Enum.MouseBehavior.Default

Yes, I know that way of doing RBXConnections is bad


Oh yeah, people uses a computer don’t that except for mobile devices.

it doesn’t do anything, because it is just enabling option for player to shiftlock manualy

No, it will work guys.

This gonna work.

1 Like

then how the heck people get shift lock forced on tools

game:GetService"UserInputService".MouseBehavior = Enum.MouseBehavior.LockCenter

The heck was enable the EnableMouseLock properties.

This function work for all devices.

i believe using userinputservice does the same result

i can still move the mouse after

Perhaps it would help more if you explained to us why you want shift lock to be forced?

game.Workspace.CurrentCamera.CameraType = "Fixed"

There is some code on the website Customizing the Camera | Roblox Creator Documentation

local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local cameraOffset =, 2, 8)
local player = Players.LocalPlayer
	local humanoid = character:WaitForChild("Humanoid")
	local rootPart = character:WaitForChild("HumanoidRootPart")
	humanoid.AutoRotate = false
	local cameraAngleX = 0
	local cameraAngleY = 0
	local function playerInput(actionName, inputState, inputObject)
		-- Calculate camera/player rotation on input change
		if inputState == Enum.UserInputState.Change then
			cameraAngleX = cameraAngleX - inputObject.Delta.X
			-- Reduce vertical mouse/touch sensitivity and clamp vertical axis
			cameraAngleY = math.clamp(cameraAngleY-inputObject.Delta.Y*0.4, -75, 75)
			-- Rotate root part CFrame by X delta
			rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, math.rad(-inputObject.Delta.X), 0)
	ContextActionService:BindAction("PlayerInput", playerInput, false, Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
		if camera.CameraType ~= Enum.CameraType.Scriptable then
			camera.CameraType = Enum.CameraType.Scriptable
		local startCFrame = * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
		local cameraCFrame = startCFrame:ToWorldSpace(, cameraOffset.Y, cameraOffset.Z))
		local cameraFocus = startCFrame:ToWorldSpace(, cameraOffset.Y, -10000))
		camera.CFrame =, cameraFocus.Position)
local function focusControl(actionName, inputState, inputObject)
	-- Lock and hide mouse icon on input began
	if inputState == Enum.UserInputState.Begin then
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		UserInputService.MouseIconEnabled = false
		ContextActionService:UnbindAction("FocusControl", focusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)
ContextActionService:BindAction("FocusControl", focusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)

There are a few ways to achieve this.
I like the most to use without changes to the Camera Module and without lots of CFraming since BodyGyro assists with the rotation.

Here’s the full topic about this: