Help with death screen

Hello all. I’m trying to make a death screen similar to the FarCry 5 death screen for a fighting game I’m making, but I can’t seem to get the camera to reset correctly. It says that, in the explorer, the properties are just fine, but the camera still doesn’t appear to align with the player’s humanoid. I tried tweaking the camera settings but nothing seems to work.

--In a localscript...

local PlayerServ = game:GetService("Players")
local Player = PlayerServ.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")


--<><><><>---

local function ResetCamera()
	task.wait()
	Camera.CameraType = Enum.CameraType.Custom
end

local function Death()
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CFrame.lookAt(Character:FindFirstChild("Head").Position,Character:FindFirstChild("HumanoidRootPart").Position)
	local CameraCFrame = Camera.CFrame
	CameraCFrame += Vector3.new(0,6,0)
	local Info = TweenInfo.new(3,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
	TweenService:Create(Camera,Info,{CFrame = CameraCFrame + Vector3.new(0,6,0)}):Play()
	
end

local EventFolder = game:GetService("ReplicatedStorage"):WaitForChild("Events")

EventFolder.DeathFXEvent.OnClientEvent:Connect(function()
	Death()
end)

EventFolder.ResetCameraEvent.OnClientEvent:Connect(function()
	ResetCamera()
end)

--In a serverscript...

local RS = game:GetService("ReplicatedStorage")
local PlayerServ = game:GetService("Players")
local Events = RS:WaitForChild("Events")

PlayerServ.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid
		Humanoid.Died:Connect(function()
			Events.DeathFXEvent:FireClient(Player)
		end)
	end)
	Player.CharacterRemoving:Connect(function(Character)
		Events.ResetCameraEvent:FireClient(Player)
	end)
end)

Any help or tips? Thanks!

If it helps, here’s a video:

I believe you need to set the camera subject to the player’s humanoid, after they have respawned

(Camera.CameraSubject = Character.Humanoid)

3 Likes

I’ll try this and let you know how it goes.

Solved! Thanks a lot! I basically just had to send data to the client about which character the event is running on so I could use that humanoid to set the camera to (and the new camerasubject). I appreciate the help!

1 Like

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