I assume this is because of the fact that the player loads before the StarterGui is loaded/initialized. Making the script just not work. And the script reloads every time the player loads due to the fact of respawn. So the player spawns. Then the script loads. And the event doesn’t fire, which doesn’t initialize the .Died event, making it so that the script thinks there is no player, because the player loads before the script.
TLDR: Player loads before script loads.