Saving variables?

Hello, I am trying to display the player's score (which I have as a static variable) from one scene to the next. I am not taking about player prefs. How can I do this? I know about

function Awake () {
    DontDestroyOnLoad (transform.gameObject);

but from what I can see, that only works on entire game objects, I just want to save one script (and not the whole game object). Thanks.

A simple example on how to use static variables to maintain data that lives through level loads would be to use this script on a new game object and have it be dedicated to keep Static Variables. That way nothing else is kept running between levels (such as the player, reading a comment you wrote earlier).


static var score : int = 0;

function Awake()
{ = "Static Variables";
    score = 0;

And then you can access the data simply in another script:

GameVars.score += 500;

Why not have your score be a `static` class variable and access that from your script regardless of its `GameObject`?

Its a static var, so if I call from another scene, its fine.