Score and HighScore saving script [please help]

Hello i just wanted to ask if anyone knows how to save score when stopping the game i made that when you kill enemy that score is going up by 10 and when you kill and kill it is going up but when i stop the game to edit or try something its going back to 0 can anyone help me how can i make so there is score and high score and then when you die or you stop the game high score is your best run but score resets to 0 like it does

the first picture is from Score 157368-screenshot-36.pngScript and second picture is from Enemy script

ScoreScript.scoreValue += 10 isn’t getting called at all, you are completely deleting the object this script is on with Destroy(gameObject), put ScoreScript.scoreValue += 10 above Destroy(gameObject):

if(health <= 0){ Destroy(gameObject); ScoreScript.scoreValue += 10; }

One simple option to save your game high scores is to use PlayerPrefs to save your game state.

For example:

Save (on game over): PlayerPrefs.SetInt("highscore", highScoreValue); PlayerPrefs.Save();

Read (at game start): highScoreValue = PlayerPrefs.GetInt("highscore");