so im trying to display the amount of coins i have on a text object which works until i reload the scene then the amount of coins is reset. any help will be much appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CoinPickup : MonoBehaviour {
public AudioSource coinsound;
public Text CoinText;
public int coincount = 0;
void OnTriggerEnter(Collider Other){
if(Other.CompareTag("Coin")){
coincount += 1;
Destroy(Other.gameObject);
coinsound.Play();
}
}
void Update (){
PlayerPrefs.SetInt ("coincount", coincount);
CoinText.text = "Power Crystals: " + PlayerPrefs.GetInt ("coincount");
//"Power Crystals: " + coincount;
}
void Awake(){
PlayerPrefs.GetInt ("coincount");
PlayerPrefs.Save();
}
}