How to fix camera not resetting after death?

I’m making a camera death effect, and want to have the camera track the player from a fixed angle.

So far it works, but after the player respawns the camera stays in the same position, is there anyway for me to check when they respawn in the context of this script without remote events?

Script:

task.wait()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local cam = workspace.CurrentCamera

hum.Died:Connect(function()
	game:GetService("RunService").RenderStepped:Connect(function()
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CFrame = CFrame.lookAt(cam.CFrame.Position, hrp.Position)
	end)
	task.wait(1)
	script.Reverse:Play()
	task.wait(1.2)
	script.Parent.Black.BackgroundTransparency = 0
end)

1 Like

Does not work, I don’t think this will work in the context of my script. All of these effects happen after the character is already loaded.

oh i just realised, its because you have RenderStepped on

why ru in need of that anyway can’t you remove it?

I am updating the cameras orientation to look at the player when he dies, if I didn’t do this on renderstepped it would only happen once.

you should create a connection for the RenderStepped Event and then disconnect it like so

local con
con = game:GetService("RunService").RenderStepped:Connect(function()

con:Disconnect()

this doesn’t really help as I need a way to detect when the player respawns, and characterAdded does not work.

myb try to fire a remote event whenever the character gets added in the server?
ServerScript

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
game.ReplicatedStorage.Remote:FireClient(plr)
end)
end)

LocalScript

game.ReplicatedStorage.Remote.OnClientEvent:Connect(function()
con:Disconnect()
end)
1 Like

In my original response I specifically stated that I wanted to avoid using remote events, as I want this to all be handled on the client, but I guess I might have no choice

not really sure if you can do it by another way
try this

hum.Died:Connect(function()
	game:GetService("RunService").RenderStepped:Connect(function()
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CFrame = CFrame.lookAt(cam.CFrame.Position, hrp.Position)
	end)
	task.wait(1)
	script.Reverse:Play()
	task.wait(1.2)
	script.Parent.Black.BackgroundTransparency = 0
        repeat wait() until hum.Health == hum.MaxHealth
        if hum.Health == hum.MaxHealth then
        con:Disconnect()
        end
end)

This doesn’t work, but the remote event implementation works fine. Thanks for the help.

1 Like

This script should also be placed inside the StarterCharacterScripts container if you want it to execute each time a player’s character is added/loaded. This should also circumvent the ‘RemoteEvent’ object dependence.