Setting RootPart's CFrame upon respawn does not work?

I am making a respawn system that saves the CFrame of a humanoid’s RootPart and immediately spawns the character in that CFrame. Apparently, the below code only respawns the character at the center of the map.

Players.PlayerAdded:Connect(function(player)
	local deathCFrame
	
	player.CharacterAdded:Connect(function(character)		
		local humanoid = character:WaitForChild("Humanoid")
		
		if deathCFrame then humanoid.RootPart.CFrame = deathCFrame end --deathCFrame is nil when the character is added for the first time upon joining the game, hence the if statement.
		
		humanoid.Died:Connect(function()
			deathCFrame = humanoid.RootPart.CFrame --sets deathCFrame to where the character has died
			
			player:LoadCharacter()
		end)
	end)
end)

Died does not fire on the server for characters that are not server controlled. Do this on the client.