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!