How would I set the CameraSubject when the player loads in

Hello everyone, I made a script where when a player dies, they spectate their body. However, it seems like the game is automatically setting the CameraSubject to Humanoid when the player respawns, which basically overrides my script.

Here is the code:

--When player character loaded
local Camera = workspace.CurrentCamera
local corpse = game.Workspace.Corpses:FindFirstChild(plr.Name)
if corpse then
	Camera.CameraSubject = corpse.HumanoidRootPart

I want to be able to set the CameraSubject smoothly without having to rely on a “wait(0.3)” because it looks choppy that way.

You could try to check whether the Humanoid’s health is 0 (dead).

For the first line of code (this might not help at all) you could try:

local Player = game.Players.LocalPlayer
print(Player) -- to see who is our player