Collapse Sidebar




This property is the DataType/CFrame of the Camera and definies its position and orientation in the 3D world.

Some transformations, such as the rotation of the head when using VR devices are not reflected in this property. For this reason, developers should use Camera/GetRenderCFrame to obtain the ‘true’ DataType/CFrame of the camera.

How to set the camera’s CFrame

You can move the camera by setting the CFrame property. However, the default camera scripts also set the CFrame property. When manually setting the CFrame property, it may be overwritten by the camera scripts which update every frame. There are two options to address this:

  1. Set the camera Camera/CameraType to ‘Scriptable’. When the camera is ‘Scriptable’ the default scripts will not update the CFrame. This method is simplest and recommended in most cases

  2. Replace the default camera scripts with an alternative that doesn’t interfere with the developer’s desired implementation. This is only recommended when developers do not need any default camera’s functionality

How the Camera CFrame works

Like all DataType/CFrame|CFrame data, the camera CFrame represents a position and an orientation.

The most intuitive way to position and orientate the Camera is by using the new CFrame constructor with the pos and lookAt parameters, for example:

local pos = Vector3.new(0, 10, 0)
local lookAt = Vector3.new(10, 0, 0)
local cameraCFrame = CFrame.new(pos, lookAt)
workspace.CurrentCamera.CFrame = cameraCFrame

In the above example the Camera is positioned at Vector3.new(0, 10, 0) and oriented to be looking towards Vector3.new(10, 0, 0).

Animating the Camera CFrame

Although the camera can be placed in the manner demonstrated above, you may want to animate the Camera to smoothly move from one CFrame to another. For this, there are a number of options:

  1. Creating a Tween using TweenService that animates the CFrame property of the camera. See the code sample below for an example of this
  2. Setting the camera CFrame every frame with RunService/BindToRenderStep and the lerp CFrame method

Code Samples

Basic Camera Cutscene

In this code sample a simple Camera animation is played after the Players/LocalPlayer spawns using TweenService. The Camera/CameraType of the Camera is set to ‘Scriptable’ so the default camera scripts do not interfere.

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera

function playCutscene(character)
	local primaryPart = character.PrimaryPart

	camera.CameraType = Enum.CameraType.Scriptable 

	local baseCFrame = primaryPart.CFrame * CFrame.new(0, 0, -100) * CFrame.Angles(0, math.pi, 0)
	local targetCFrame = primaryPart.CFrame * CFrame.new(0, 0, -10) * CFrame.Angles(0, math.pi, 0)

	camera.CFrame = baseCFrame 

	local tween = TweenService:Create(
		{CFrame = targetCFrame}

	camera.CameraType = Enum.CameraType.Custom