If the player kills the NPC, it crashes

Thank you so much for your answer!! If the NPC dies as chrudimer says, the Player is null (because Character is coming over to the NPC)
I don’t have a clue how to write the code..

The language may not be natural because of the use of a translator.