Ok I have been struggling for a fair amount of time now and I am not that great at coding as is =(. Basically I would like to save my currentScore variable so that when the level is finished I can then load it up in a new level. Below is the code and I would very much appreciate any help. Thank you for your time.

public var currentScore = 0;

var increaseScore = 20;

var myStyle : GUIStyle;

function playerScore()


currentScore += increaseScore;


function OnGUI ()


GUI.Label (Rect (Screen.width - 200,0,200,50),"Score: " + currentScore, myStyle);


If you where looking to use PlayerPrefs to save the currentScore Intager, you can do so like this:

PlayerPrefs.SetInt("CurrentScore", currentScore);

And retrieve it again in the next Scene, or the next run like this:


For more documentation/examples see the Unity Docs.

You could just make the variable static, then it will be one value for all instances - or you could have that object not destroy itself on load (by calling Object.DontDestroyOnLoad()).

 public static var currentScore = 0;