Codectionary / Developer documentation / Luau

Camera control

Set a client camera viewpoint for a short scripted shot.

Why use Camera?

The current Camera determines what one player sees. Scriptable mode allows code to set its CFrame; camera control belongs on the client because each player has a different view.

Try it in Roblox Studio

Put this LocalScript in StarterPlayerScripts. Run a client in Studio; the camera briefly looks toward the origin, then returns to default control.

Syntax

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.lookAt(from, target)

Examples

Camera control

Show a short scripted view and restore player control.

local camera = workspace.CurrentCamera
if camera then
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = CFrame.lookAt(Vector3.new(0, 15, 25), Vector3.new(0, 0, 0))
    task.wait(3)
    camera.CameraType = Enum.CameraType.Custom
end
  1. CurrentCamera is the client’s active camera.
  2. Scriptable mode stops the default camera controller from setting its frame while the example sets a viewpoint.
  3. Returning to Custom restores the normal camera behavior; production camera systems should also handle character respawns and interruptions.

Best practices

  • Control each player’s camera in a LocalScript.
  • Restore an appropriate camera mode when a cutscene ends.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading