Tutorial · Gameplay

How to force first person in Roblox Studio

Horror games, shooters and escape rooms often keep the camera inside the player's head. In Roblox that is one property: set CameraMode to LockFirstPerson and players can no longer zoom out. This guide starts with that setting, then adds a key that switches between first and third person, rooms that lock first person only while you are inside, and how to turn shift lock off or force an over-the-shoulder view.

Updated 14 November 20268 min readBeginnerLuauWritten by

In short

Select StarterPlayer in the Explorer and set CameraMode to LockFirstPerson in the Properties window. Every player is then locked in first person. To switch it in a script, set player.CameraMode = Enum.CameraMode.LockFirstPerson, and back to Enum.CameraMode.Classic for third person, raising CameraMinZoomDistance for a moment so the camera zooms back out.

  • A setting on StarterPlayer applies to everyone. The same property on a Player changes only that player.
  • In first person the mouse is locked to the middle of the screen. A visible GuiButton with Modal ticked frees it for menus.
  • Shift lock is switched off with EnableMouseLockOption on StarterPlayer. Roblox says the shift lock APIs are being deprecated and recommends UserInputService.MouseBehavior for new code.

Get the script

First and third person toggle script

One LocalScript in StarterPlayerScripts: press V, or the View button on a phone, to switch between a locked first person view and third person.

LocalScript in StarterPlayerScripts named CameraToggle
-- LocalScript in StarterPlayerScripts named CameraToggle.
-- Press V (or the View button on a phone) to switch between first and third person.
local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")

local START_IN_FIRST_PERSON = true
local THIRD_PERSON_DISTANCE = 12 -- studs the camera zooms out to for third person

local player = Players.LocalPlayer
local normalMinZoom = player.CameraMinZoomDistance
local firstPerson = false

local function setFirstPerson(on: boolean)
	firstPerson = on
	if on then
		player.CameraMode = Enum.CameraMode.LockFirstPerson
	else
		player.CameraMode = Enum.CameraMode.Classic
		-- Leaving first person keeps the camera zoomed in. Raising the minimum zoom
		-- for a moment pushes it out, then the player can zoom freely again.
		player.CameraMinZoomDistance = math.min(THIRD_PERSON_DISTANCE, player.CameraMaxZoomDistance)
		task.delay(0.1, function()
			if not firstPerson then
				player.CameraMinZoomDistance = normalMinZoom
			end
		end)
	end
	ContextActionService:SetTitle("ToggleView", if on then "3rd" else "1st")
end

local function onToggle(_name: string, state: Enum.UserInputState, _input: InputObject): Enum.ContextActionResult
	if state == Enum.UserInputState.Begin then
		setFirstPerson(not firstPerson)
	end
	return Enum.ContextActionResult.Pass
end

ContextActionService:BindAction("ToggleView", onToggle, true, Enum.KeyCode.V, Enum.KeyCode.ButtonSelect)
setFirstPerson(START_IN_FIRST_PERSON)

-- A new character keeps the Player's CameraMode, but set it again in case another script changed it
player.CharacterAdded:Connect(function()
	setFirstPerson(firstPerson)
end)

RoCode builds it in the place you have open in Roblox Studio, on Windows or macOS with a desktop browser; on a phone the button sends the prompt and the link to your computer. Free to start, with free credits every day. More Roblox Studio scripts

Where to put it

Explorer: one LocalScript
StarterPlayer
  StarterPlayerScripts
    CameraToggle LocalScript new

Settings you can change

START_IN_FIRST_PERSONIn the script
Whether players start in first person. Default: true.
THIRD_PERSON_DISTANCEIn the script
How far, in studs, the camera zooms out when switching to third person. Default: 12.

Leave StarterPlayer's CameraMode on Classic when you use this script, so the script is the only thing deciding the view.

Type-checked with luau-lsp strict against Roblox's API definitions on 14 November 2026. Not playtested in Studio yet: press Play and watch the Output window before you publish.

Prompt for RoCode

Add a first person toggle to my game: a LocalScript in StarterPlayerScripts that starts players in first person with CameraMode LockFirstPerson, switches to third person and back on V or a phone button with ContextActionService, zooms the camera out to 12 studs when going to third person by raising CameraMinZoomDistance for a moment, and works after respawning.

On this page
  1. Get the script
  2. How it works
  3. 1. No code
  4. 2. Toggle
  5. 3. Zones
  6. 4. Shift lock
  7. 5. Arms
  8. 6. Test
  9. Common errors
  10. With RoCode
  11. Questions
  12. Sources

How the Roblox camera modes work

Every player has a CameraMode. Its starting value comes from StarterPlayer, and each Player object then has its own copy that scripts can change.

The two camera modes
CameraModeWhat the player gets
Classic (default)Third person. The player can zoom in to first person and out again with the mouse wheel or a pinch.
LockFirstPersonThe camera is zoomed all the way in and cannot zoom out. Moving the mouse turns the camera and the character.

Two more StarterPlayer properties control the zoom: CameraMinZoomDistance and CameraMaxZoomDistance. Setting both to the same number fixes the camera at that distance, which is another way to lock a view, such as a fixed third person camera at 10 studs.

Step 1: Force first person with no code

  1. In the Explorer, click StarterPlayer.
  2. In the Properties window, find CameraMode under Camera and change it to LockFirstPerson.
  3. Press Play. The camera is in your head and the mouse wheel does nothing.

That is all a horror game or a shooter usually needs. Your own body is hidden in first person: Roblox fades out your body parts on your screen only, using LocalTransparencyModifier, so other players still see you. Step 5 shows how to keep your arms visible.

Step 2: Toggle first and third person on V

Some games let players choose. This LocalScript switches between a locked first person view and the normal third person camera when the player presses V. On phones it adds a View button.

  1. Set StarterPlayer's CameraMode back to Classic.
  2. Expand StarterPlayer, hover over StarterPlayerScripts, click + and insert a LocalScript named CameraToggle.
  3. Paste the code below and press Play. Press V to switch.
LocalScript in StarterPlayerScripts named CameraToggle
-- LocalScript in StarterPlayerScripts named CameraToggle.
-- Press V (or the View button on a phone) to switch between first and third person.
local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")

local START_IN_FIRST_PERSON = true
local THIRD_PERSON_DISTANCE = 12 -- studs the camera zooms out to for third person

local player = Players.LocalPlayer
local normalMinZoom = player.CameraMinZoomDistance
local firstPerson = false

local function setFirstPerson(on: boolean)
	firstPerson = on
	if on then
		player.CameraMode = Enum.CameraMode.LockFirstPerson
	else
		player.CameraMode = Enum.CameraMode.Classic
		-- Leaving first person keeps the camera zoomed in. Raising the minimum zoom
		-- for a moment pushes it out, then the player can zoom freely again.
		player.CameraMinZoomDistance = math.min(THIRD_PERSON_DISTANCE, player.CameraMaxZoomDistance)
		task.delay(0.1, function()
			if not firstPerson then
				player.CameraMinZoomDistance = normalMinZoom
			end
		end)
	end
	ContextActionService:SetTitle("ToggleView", if on then "3rd" else "1st")
end

local function onToggle(_name: string, state: Enum.UserInputState, _input: InputObject): Enum.ContextActionResult
	if state == Enum.UserInputState.Begin then
		setFirstPerson(not firstPerson)
	end
	return Enum.ContextActionResult.Pass
end

ContextActionService:BindAction("ToggleView", onToggle, true, Enum.KeyCode.V, Enum.KeyCode.ButtonSelect)
setFirstPerson(START_IN_FIRST_PERSON)

-- A new character keeps the Player's CameraMode, but set it again in case another script changed it
player.CharacterAdded:Connect(function()
	setFirstPerson(firstPerson)
end)

The script changes the CameraMode of the local Player only, so each player chooses their own view. Switching to first person is instant. Switching back needs a nudge: Classic mode lets the player zoom, but it does not zoom out by itself. Setting CameraMinZoomDistance to 12 forces the camera at least 12 studs away, and a tenth of a second later the script restores the old minimum so the player can zoom back in with the wheel.

The gamepad input is the Select button (ButtonSelect), which few games use for anything else. Change the KeyCodes in BindAction to use different keys. The UserInputService guide explains KeyCodes and input types.

Step 3: First person only inside some rooms

A horror game might use third person outside and lock first person inside the haunted house. Mark each area with an invisible part and tag it FirstPersonZone, and this LocalScript locks the camera while the player stands inside one.

  1. Insert a Part that covers the room. Set Transparency to 1, untick CanCollide and CanTouch, and tick Anchored.
  2. In its Properties, under Tags, click + and type FirstPersonZone.
  3. Insert a LocalScript in StarterPlayerScripts named FirstPersonZones and paste the code below. Do not use it together with CameraToggle: both set CameraMode.
LocalScript in StarterPlayerScripts named FirstPersonZones
-- LocalScript in StarterPlayerScripts named FirstPersonZones.
-- Inside any part tagged FirstPersonZone, the camera is locked in first person.
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local OUTSIDE_DISTANCE = 12 -- studs the camera zooms out to when leaving a zone

local player = Players.LocalPlayer
local normalMinZoom = player.CameraMinZoomDistance
local inside = false

local function isInside(zone: BasePart, position: Vector3): boolean
	-- The position in the zone's own space is inside when every axis is within half its size
	local offset = zone.CFrame:PointToObjectSpace(position)
	local half = zone.Size / 2
	return math.abs(offset.X) <= half.X and math.abs(offset.Y) <= half.Y and math.abs(offset.Z) <= half.Z
end

RunService.Heartbeat:Connect(function()
	local character = player.Character
	local root = character and character:FindFirstChild("HumanoidRootPart")
	if not (root and root:IsA("BasePart")) then
		return
	end
	local nowInside = false
	for _, zone in CollectionService:GetTagged("FirstPersonZone") do
		if zone:IsA("BasePart") and isInside(zone, root.Position) then
			nowInside = true
			break
		end
	end
	if nowInside == inside then
		return -- nothing changed this frame
	end
	inside = nowInside
	if inside then
		player.CameraMode = Enum.CameraMode.LockFirstPerson
	else
		player.CameraMode = Enum.CameraMode.Classic
		player.CameraMinZoomDistance = math.min(OUTSIDE_DISTANCE, player.CameraMaxZoomDistance)
		task.delay(0.1, function()
			if not inside then
				player.CameraMinZoomDistance = normalMinZoom
			end
		end)
	end
end)

The camera is a choice about one player's screen, so a LocalScript is the right place for it. If being in first person should matter for gameplay, such as a stealth bonus, the server has to check where the player is itself. The same zone idea also drives music zones and the low gravity zone.

Step 4: Shift lock: turn it off or force it on

Shift lock is the setting players switch on in the Roblox menu that locks the mouse to the centre, turns the character with the camera and moves the view over the right shoulder.

Turn shift lock off

Select StarterPlayer and untick EnableMouseLockOption. It sets the starting value of each player's DevEnableMouseLock. To change it for one player during the game, set player.DevEnableMouseLock from a server Script: Roblox's reference says it can be set server-side and not client-side. Roblox also notes that the shift lock APIs are being deprecated and recommends UserInputService.MouseBehavior instead, which is what the next script uses.

Force an over-the-shoulder lock

Shooters and battlegrounds games often keep everyone in a shift-lock style view. This LocalScript locks the mouse to the centre, turns the character to face where the camera looks and moves the camera over the right shoulder, every frame. Untick EnableMouseLockOption first so the menu setting does not fight it.

LocalScript in StarterPlayerScripts named ForcedShoulderLock
-- LocalScript in StarterPlayerScripts named ForcedShoulderLock.
-- Locks the mouse, turns the character with the camera, and puts the camera over the right shoulder.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local SHOULDER_OFFSET = Vector3.new(1.75, 0, 0) -- studs right of the character

local player = Players.LocalPlayer

-- Run just after the default camera so its own mouse setting does not win
RunService:BindToRenderStep("ForcedShoulderLock", Enum.RenderPriority.Camera.Value + 1, function()
	local character = player.Character
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")
	local root = humanoid and humanoid.RootPart
	local camera = workspace.CurrentCamera
	if not (humanoid and root and camera) or humanoid.Health <= 0 then
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		return
	end
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	humanoid.AutoRotate = false -- the script turns the character instead of the walk direction
	humanoid.CameraOffset = SHOULDER_OFFSET
	-- Face the way the camera looks, flattened so the character stays upright
	local look = camera.CFrame.LookVector
	local flat = Vector3.new(look.X, 0, look.Z)
	if flat.Magnitude > 0.01 then
		root.CFrame = CFrame.lookAt(root.Position, root.Position + flat)
	end
end)

The player's device moves its own character, so turning the root part from a LocalScript is fine and other players see the character turn. AutoRotate off stops the Humanoid from turning the character to face its walk direction, which would fight the script. CameraOffset shifts the camera relative to the root part, so 1.75, 0, 0 is over the right shoulder. On phones and gamepads there is no mouse to lock, and the character still faces the camera.

Step 5: See your arms in first person

In first person Roblox hides your whole body on your screen by setting each part's LocalTransparencyModifier. A game where players hold tools often wants the arms to stay visible. This LocalScript in StarterCharacterScripts sets the arms back to visible every frame, after the camera hides them.

LocalScript in StarterCharacterScripts named ShowArms
-- LocalScript in StarterCharacterScripts named ShowArms.
-- Keeps your arms visible in first person (R15 and R6 arm names).
local RunService = game:GetService("RunService")

local character = script.Parent :: Model

local ARM_NAMES: { [string]: boolean } = {
	LeftUpperArm = true, LeftLowerArm = true, LeftHand = true,
	RightUpperArm = true, RightLowerArm = true, RightHand = true,
	["Left Arm"] = true, ["Right Arm"] = true,
}

RunService:BindToRenderStep("ShowArms", Enum.RenderPriority.Camera.Value + 1, function()
	for _, part in character:GetChildren() do
		if part:IsA("BasePart") and ARM_NAMES[part.Name] then
			part.LocalTransparencyModifier = 0
		end
	end
end)

character.AncestryChanged:Connect(function()
	if not character.Parent then
		RunService:UnbindFromRenderStep("ShowArms")
	end
end)

LocalTransparencyModifier only changes how the part looks on this player's screen and does not replicate. The camera sits inside your head, so with arms visible you see them when you look down or hold a tool out in front.

Step 6: Test it

  1. With StarterPlayer's CameraMode on LockFirstPerson, press Play: the mouse wheel cannot zoom out.
  2. With the CameraToggle script instead, press V: the camera jumps out to third person; press V again to go back in.
  3. Walk into a FirstPersonZone part and out again: the camera locks inside and zooms out when you leave.
  4. Open a menu with a Modal button in first person: the cursor is free while it is on screen.
  5. Test on a phone with Studio's device emulator: the View button switches the camera.

Common errors and fixes

If the camera does not change, check the Output window first: a red line names the script and the line.

Players can still zoom out

Another script sets CameraMode back to Classic, or the property was set on a single Player in Studio instead of on StarterPlayer. Set it on StarterPlayer, or from a LocalScript with Players.LocalPlayer.CameraMode.

The camera stays zoomed in after leaving first person

Classic mode does not zoom out by itself. Raise CameraMinZoomDistance for a moment, as the toggle script does, then put it back.

I cannot click my shop button in first person

The mouse is locked to the centre. Tick Modal on a visible button in the menu, and the cursor is free while the menu shows.

Shift lock still works

Untick EnableMouseLockOption on StarterPlayer. Changing DevEnableMouseLock from a LocalScript does nothing: it can only be set from the server.

The character spins when walking with the forced shoulder lock

AutoRotate is still on, so the Humanoid and the script both turn the character. Check that humanoid.AutoRotate = false runs.

Build it with RoCode

If you would rather not set this up by hand, RoCode can build it in the place you have open. RoCode is an independent AI agent for Roblox Studio, not made by Roblox: you describe the change in a web chat, and its Studio plugin creates the parts and scripts in your Explorer, so there is no code to paste.

You type

Lock my horror game in first person inside the house, normal third person outside, and make sure the pause menu button can still be clicked.

RoCode does
  • Can read your place first to find your rooms and menus, then adds the zone parts and the LocalScript
  • Writes the scripts with Create Script and is told to compile-check each one with Check Script
  • Sets an undo point before and after each batch of changes, so Ctrl+Z steps back one batch at a time

After a build, RoCode can run its test robot: it plays your game in Studio and reports PASS or FAIL. It checks only what it chose to test, so walk through your rooms yourself too. How RoCode connects to Studio.

Questions

How do you force first person in Roblox Studio?

Select StarterPlayer and set CameraMode to LockFirstPerson. No script is needed.

How do I make a first person toggle in Roblox?

In a LocalScript, set player.CameraMode to LockFirstPerson or Classic when a key is pressed, and raise CameraMinZoomDistance for a moment when going back to third person. Step 2 has the script.

How do I disable shift lock in Roblox Studio?

Untick EnableMouseLockOption on StarterPlayer. For one player during the game, set DevEnableMouseLock to false from a server Script.

How do I force shift lock on?

Use a LocalScript that sets UserInputService.MouseBehavior to LockCenter every frame, turns AutoRotate off and turns the character to face the camera. Step 4 has it.

Why can I not see my body in first person?

Roblox hides your body parts on your own screen with LocalTransparencyModifier. Set it back to 0 for the parts you want to see, as Step 5 does for the arms.

Sources and further reading

How the code was checked: every script on this page passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 14 November 2026). A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

Try RoCode on your own place.

Free every day, no card required. Install the plugin, describe the feature, and review what lands in Studio.