There are a few ways depending on the complexity you want but one of the simplest ways is to use a variable called var_highscore and a variable called var_score.
Your var_score is set during the game and updates based on whatever your game mechanics are and when the player dies you set the var_highscore using:
On player death:
var_score > var_highscore - Set var_highscore to var_score