How do I use the "Watch" Camera Type to follow a player from a set CFrame Part

Hey! I want to achieve a still camera up in the sky with a set cframe to just follow the player. I thought I could use the CameraType of Watch but it doesn’t seem to work with a set CFrame part.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace:WaitForChild("CAMERAPART").CFrame

Camera.CameraType = Enum.CameraType.Watch
Camera.FieldOfView = 15
Camera.CameraSubject = Player.Character.HumanoidRootPart

Thanks

So you just want the camere to look down on the player?

i wrote this code for you
i hope it works fine!!

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

local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

local CameraOffset = 15 -- studs offset
local CameraSpeed = 0.05 -- 1 is instant

local function RayUp(Root,IgnoreList)
	local ray = Ray.new(Root.Position, Vector3.new(0, 1, 0).unit * CameraOffset)
	local part, pos = workspace:FindPartOnRayWithIgnoreList(ray, IgnoreList, false, true)
	if part then
		return pos
	end
end

local FPSInfo = {
	TargetFramerate = 60,
	TimePerFrame = 1 / 60,
	TotalTime = 0
}

RunService.RenderStepped:Connect(function(DeltaTime)
	FPSInfo.TotalTime = FPSInfo.TotalTime + DeltaTime

	if FPSInfo.TotalTime >= FPSInfo.TimePerFrame then
		FPSInfo.TotalTime = 0

		local Character = Player.Character

		if Character and Character:FindFirstChild("Humanoid").RootPart then
			local Root = Character.Humanoid.RootPart
			local CalculatedOffset = 0
			
			local RayPos = RayUp(Root, {Character})
			
			if RayPos then
				CalculatedOffset = (Root.Position.Y-Camera.CFrame.Position.Y)
			end
			
			local NewCF = Camera.CFrame:Lerp(Root.CFrame * CFrame.new(0, CameraOffset+CalculatedOffset, -0.1) * CFrame.Angles(math.rad(-90), 0, 0), CameraSpeed)
			Camera.CFrame = NewCF
		end
	end
end)

OR

if you just want the camera to follow instantly and not have any smoothness at all you can always just do this example:

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

local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

local CameraOffset = 15 -- studs offset

RunService.Heartbeat:Connect(function()
	local Character = Player.Character

	if Character and Character:FindFirstChild("Humanoid").RootPart then
		local Root = Character.Humanoid.RootPart
		
		Camera.CFrame = Root.CFrame * CFrame.new(0, CameraOffset, 0) * CFrame.Angles(math.rad(-90), 0, 0)
	end
end)

Thank you! Ill try this and come back!

Keep it as Scriptable

while true do
     task.wait()
     camera.CFrame = CFrame.lookAt(workspace:WaitForChild("CAMERAPART").CFrame, Player.Character.HumanoidRootPart.CFrame)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.