Keeping score after death (SOLVED)

What i want is, if the player dies and restarts they keep the score they had before dieing.
i tried:

function Awake () {
    DontDestroyOnLoad (playerScore);
}

but i kept getting a compatibility error.
how can i keep my score after dieing?
Thanks for the help, and sorry if its something obvious,still new :lol:

use PlayerPrefs and save the variable. Unity - Scripting API: PlayerPrefs

gaaah, my problems are always soooo simple, but this is a great find for me!!!

thanks so much :smile:

I don’t get how that link helped. I couldn’t locate any of those directories on my PC. i am wondering he same thing about keeping player scores but am just as lost as before reading the “answered” question

you’ll probably find necro’ing a thread with “solved” in the title is going to kill your view rate too.

to use playerprefs you don’t have to do anything with the folders/file/whatever. Just look at the Set/Get function pairs (i.e. SetFloat(…) GetFloat(…))