PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
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 Players/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’s Model/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 Players/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