I can't save my money? :<

Hello friends, I writed a basic script but I can’t save my money(like score). I’m not want best score or something. What is wrong?

Thats the basic money script;

static var moneys = 0;

function Update()
{
	PlayerPrefs.GetInt("dollarf");
	PlayerPrefs.SetInt("dollarf",moneys);	
}

And thats the Int sender to text script;

var dollarText : UnityEngine.UI.Text;

function Update () {
	dollarText.text =  "Money "  + PlayerPrefs.GetInt("dollarf");
	
}

When I adding money with this script;

function Update () {
	if(Input.GetKey(KeyCode.L)){
	dollarsystem.moneys +=10;
	}
}

I only see when I back to menu, It’s saved. But when I stop playing and restarting the game It’s going… What’s wrong?

Hi,
Your problem here is in this code

static var moneys = 0; // Sets the value zero
 
 function Update()
 {
     PlayerPrefs.GetInt("dollarf"); // fetching  the value....lets say its 50
     PlayerPrefs.SetInt("dollarf",moneys);    //Now passing the value of money which is 0 so the value in dollarf becomes zero.
 }

Here you are supposed to do something like this… so that your stored value is not disturbed.

PlayerPrefs.SetInt("dollarf",( PlayerPrefs.GetInt("dollarf")+moneys)); 

Hope you have understood the problem.