Hello, i am new in unity and i am reading everything i can, tutorials,youtube,etc

Well, i am developing a game, at this time it has 3 scenes:

  1. MainMenu (Should display a button to start and a best score)
  2. Gameplay (player can play and do so score, at the end gameplay save it on PlayerPrefs
  3. RetryMenu (Should display best score and last score)

This variable Score is Stored on Scene Gameplay and on a script called “GameMaster”, this script controls the game and has some important variables like Score.
At the end of game i run this code

PlayerPrefs.SetInt("Player Score", Score);

When the game ends i call the Retry Scene and i try to read from playerPref

LastScore.text = PlayerPrefs.GetInt("Player Score").ToString();

It returns a error

Assets/Scripts/GameMaster.js(104,40): BCE0020: An instance of type 'GameMaster' is required to access non static member 'Score'.

My question is, why do i need playerpref to save information if i cant use them outside Scenes? Or can i? If yes, how can i pass the instance? hum…

(to resolve this problem i am thinking on writing on a txt and then read it each time i load a scene, is this a bad?)

EDIT: added GameMaster script

//Player
var Score: int = 0;

function Awake ()//copied this from some tutorials to not lose this instance, dunno if is needed
{
DontDestroyOnLoad (transform.gameObject);
}

function Update ()
{
...

   if(Mathf.Round(Stamina) <= 0)
   {
      EndGame();
   }
}


function EndGame()
{
	SaveProgress();
	Application.LoadLevel("Retry");
}

static function SaveProgress () {
    PlayerPrefs.SetInt("Player Score", Score);
}

It appears that your problem is that you’re not using PlayerPrefs correctly.

To save to player prefs, you use SetInt.

To retrieve the value, you use GetInt.

Which is backwards from what you described.

I also don’t quite understand why you’d have a static save progress function…