roblox-camera

roblox-camera

Popular

Use when scripting, fixing or reviewing Roblox cameras: occlusion, screen raycasts, shift lock, zoom, first person, shake, cutscenes, spectate.

229stars
26forks
Updated 11/30/2026
SKILL.md
read-only
name
roblox-camera
description

Use when scripting, fixing or reviewing Roblox cameras: occlusion, screen raycasts, shift lock, zoom, first person, shake, cutscenes, spectate.

Roblox Camera

When to Load

Changing the default camera's behaviour or replacing it: occlusion, screen-to-world rays, zoom and mouse-lock settings, first person, shake and recoil, cutscenes, spectate. Input binds: roblox-input; screen insets and safe areas: roblox-ui §1.

"Field case" = seen in one of the owner's projects; verify on your content.

Traps and review checklist (symptom -> cause -> fix)

  • Camera clips through walls after a map rebuild (meshes + invisible collision boxes) -> the default camera only pulls in for parts that are CanCollide = true and mostly opaque. Visual meshes with CanCollide = false are ignored, and so are invisible proxies: Camera:GetLargestCutoffDistance (which PopperCam uses) skips CanCollide = false, Transparency > 0.95 and water; the PlayerModule's Popper source was seen skipping total transparency >= 0.25, counting LocalTransparencyModifier (check the current source). Make collidable, visible geometry stand where the walls are (§1).
  • "Fixed" occlusion still clips in Play -> property checks aren't proof. Verify against the real geometry: cast the camera's rays against the old and new map at the same sample points and compare hit distances, then back the camera into walls at known spots (§1).
  • Hiding spot, locker or vehicle shell shoves the camera in -> ghost it locally with LocalTransparencyModifier past the threshold above instead of turning off collision. DevCameraOcclusionMode (Zoom default, Invisicam) is set on StarterPlayer and can't be changed per player.
  • Aim ray off by the top bar -> mixed coordinate spaces. UserInputService:GetMouseLocation() ignores the inset -> ViewportPointToRay; InputObject.Position (mouse/touch) and ScreenPointToRay/WorldToScreenPoint include the inset. Both rays are unit length: scale Direction before Raycast.
  • Shift lock, camera mode or movement mode won't change from a LocalScript -> DevEnableMouseLock, DevComputerCameraMode, DevComputerMovementMode are server-set only (defaults from StarterPlayer); the player can still turn the mouse-lock switch off in settings, so never make shift lock the only way to aim. CameraMaxZoomDistance below CameraMinZoomDistance is raised to the minimum; equal values lock zoom.
  • Orthographic view works in Studio, not live -> Camera.ProjectionType = Orthographic (OrthographicSize, OrthographicMode) is a Studio beta; published games can't use it yet <!-- temporal: 2026-11 -->. Screen rays are parallel there; recheck world-to-screen maths.
  • View drifts after recoil, head bob or rotational shake -> the default camera reads its own CFrame back as input: ±4° kicks re-based on it drifted 1.7°-17.8° pitch and 2.7°-17.7° yaw over a few runs; translation-only shake drifted 0° (field-measured). Remove the kick before the camera step and re-apply after (§2).
  • Cutscene or test camera snaps back after setting Scriptable -> the game's own camera controller keeps writing CFrame. Bind the override at RenderPriority.Last, disable the project's first-person/viewmodel controllers for the shot, confirm the CFrame held next frame (field case).
  • Fast subject (launch, vehicle, ragdoll) trails or shakes -> an exponential follow lags by about speed / rate (~6 studs at 80 studs/s, rate 14). Lead the follow point by AssemblyLinearVelocity * dt, then lerp (average error ~0.3 studs, worst 0.95, field-measured); follow an anchored proxy moved at Camera.Value - 1, not the tumbling Head.
  • Zoom lands short after a tweened pull-in -> hold the final CameraMin/MaxZoomDistance through at least one native camera update before reopening free zoom (~0.2 studs lost per cycle otherwise); compare stored zoom with ~0.1-stud tolerance (field-measured).
  • Spare cameras vanish / ViewportFrame rays wrong -> setting Workspace.CurrentCamera destroys other Cameras directly under Workspace (keep them in a Folder or Model). Only CurrentCamera updates ViewportSize; ScreenPointToRay works only for it. Use ViewportCamera for ViewportFrame.CurrentCamera: it replicates and works in Team Create.
  • Collision-safe offset still clips at corners -> Spherecast/Blockcast don't detect parts the shape starts inside. Handle start overlaps separately, let clearance override the preferred minimum distance, and test corners, shelves and low ceilings.
  • Death cam or spectate leaves the wrong subject or locked controls after respawn -> restore to the current character and controller, not a snapshot taken before a respawn or newer camera mode; release on timeout, subject removal and round change. CameraSubject = nil reverts to the previous subject.

What changed

Change Use now
CFrame.new(pos, lookAt) replaced CFrame.lookAt(at, target, up?); near straight up/down pass your own up or use CFrame.fromMatrix (the default up flips to the X axis)
Player:GetCameraState() (Server Authority) <!-- temporal: 2026-11 --> server reads any player's CFrame/FieldOfView/ViewportSize for aim validation; CFrame comes via the input stream, FOV/size via property replication, so they can disagree; still player data (roblox-security)
Free camera Left Shift + P for owners/editors in playtests and live; its menu needs Workspace.PlayerScriptsUseInputActionSystem. Debug and footage only, not a spectator mode

1. Occlusion fix and verification (m-0083 shape)

  • Verify in Play on both maps: from the character's head, Camera:GetLargestCutoffDistance({character}) at sampled camera positions, or workspace:Raycast(focus, cameraPos - focus, params) (exclude the character) along walls, roofs and doorways. Every sample that hit on the old map must hit at about the same distance on the new one. Then walk the camera into a few walls on PC, phone and gamepad.

2. Rotational kick without drift

-- Illustrative: kick never leaks into the default camera's aim.
local CAM = Enum.RenderPriority.Camera.Value
local kick, applied = CFrame.identity, nil -- recoil code writes `kick`
RunService:BindToRenderStep("KickRemove", CAM - 2, function()
	if applied then camera.CFrame *= applied:Inverse(); applied = nil end
end)
RunService:BindToRenderStep("KickApply", CAM + 3, function()
	if kick ~= CFrame.identity then camera.CFrame *= kick; applied = kick end
end)

Several kickers nest last-on-first-off (B applied at +4 comes off at -3, before A at -2). Verify by recording pitch and yaw before a burst and after it settles, over several bursts: they must return exactly.