PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

CameraSubject

Camera

Instance

When using the default camera scripts, the CameraSubject property has two roles:

  • Defining the object the Camera is to follow, in the case of the ‘Follow’, ‘Attach’, ‘Track’, ‘Watch’ and ‘Custom’ Camera/CameraType|CameraTypes
  • For all Camera/CameraType|CameraTypes but ‘Scriptable’, the object whose position the Camera|Camera's Camera/Focus will be set to

CameraSubject accepts a variety of Instance|Instances. The default camera scripts respond differently to different CameraSubject types:

  • Humanoid: By default the CameraSubject is set to the Player/LocalPlayer|LocalPlayer's Humanoid. The camera scripts will follow the Humanoid factoring in the Humanoid|Humanoid's current state and Humanoid/CameraOffset
  • BasePart: The camera scripts will follow the position of any BasePart, with a vertical offset in the case of VehicleSeat|VehicleSeats

You can configure the Camera to follow a Model by setting the CameraSubject to the model’sModel/PrimaryPart.

The CameraSubject cannot be set to nil. If it is, it will revert to its previous value.

To restore the CameraSubject to its default value, set it to the Player/LocalPlayer|LocalPlayer's Humanoid like so:

local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer

local function resetCameraSubject()
	if workspace.CurrentCamera and localPlayer.Character then
		local humanoid = localPlayer.Character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			workspace.CurrentCamera.CameraSubject = humanoid
		end
	end
end