Camera looks at player when they die

I want to make it so when you die, the camera will look at your player until you respawn, obviously, the camera should stay in place. Any way in achieving this? I have barely any knowledge on coding, so maybe thats a problem.

It’s pretty easy to make something like that. Here’s what I did a while ago. It’s technically just a code that runs when player died. It’ll lock the camera in place and focus on player until they respawn. Oh and be sure that the players aren’t falling through the map once they died.

-- Local script

-- Variables
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local RunService

-- Repeat wait() until Humanoid exist within Player's character
repeat wait() until Player.Character and Player.Character:FindFirstChild("Humanoid")

Camera.CameraSubject = Player.Character.Humanoid
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = Player.Character.Head.CFrame

-- Died function
Player.Character.Humanoid.Died:Connect(function()
	repeat 
		wait() 
		Camera.CameraType = Enum.CameraType.Scriptable 
	until Camera.CameraType == Enum.CameraType.Scriptable
	RunService = game:GetService("RunService").RenderStepped:Connect(function()
		Camera.CFrame = CFrame.new(
			Camera.CFrame.Position, 
			Player.Character.HumanoidRootPart.Position -- Part that you want the camera to focus on
		)
	end)
end)
9 Likes

Put it in StarterGUI in an empty baseplate, works perfectly. The only problem is my game has a custom 2D camera, and the script doesn’t work…

You should put your 2D camera script here. Before AND after the script type ``` so it prints it here in a readable format.

2D Camera? May I ask how it functions? I’ve seen some of the examples in the studio starter game place maker thingy. Not sure if they’re the same with what you’re currently using?

Doesn’t work tho, When you die the camera does in fact look at you, but once you respawn, the camera will still be in the old position.