Issue with respawning player

Hi so I recently put in a re-spawn/checkpoint system and its breaking something in my blueprint. So I have an event tick ruining in a different script that checks the distance to the player

But whenever I destroy the player and then re-spawn him I get these errors

It is not game breaking but it does annoy me, does anyone have an idea of how i could fix this issue?

Yes this happens because when you destroy the player character the Get Player Character node will return a null object (since the player doesn’t exists at that moment) and thus the erros.

What you can do to solve this is to add a check to see if the player exists before trying to read its distance property. You do that with an Is Valid macro node you pass the return pin from the Get Player Character node to the Is Valid node and then you just continue with your stuff in the Is Valid execution line.

Note that this check can be added inside your Check Dist to Player function but you would need to handle the case where the playing doesn’t exist by returning something like -1 (Since there aren’t negative distances). Or you could do the check before calling your function, if the object is valid, call your function if it isn’t then don’t call it.