Using Playerprefs???

Ok. I know i’m meant to use playerprefs but i keep getting errors i want to save my high score so it displays on the main menu when you return to it and every tome you load the game up how would i do this?

The attached is what ive got that gets the score every time i go through the checkpoint any help would be really appreciated :slight_smile: Thanks.

Your problem maybe line 15 Destroy(gameObject)

If you want to destroy other object you have to use Destroy(collision.gameObject)

This is when reading:

	myScore = PlayerPrefs.GetInt("score");
	myScore = 0;

This is for writing:

	PlayerPrefs.SetInt("score", Mathf.Max(myScore, PlayerPrefs.GetInt("score"));
	PlayerPrefs.SetInt("score", myScore);

Good luck :slight_smile:

Try changing this line:

if(collision.gameObject.tag == "walls";

With this one:

if (collision.CompareTag ("walls")) {

If you get an error add gameObject to it:

if (collision.gameObject.CompareTag ("walls")) {

Please let met know if this fixed your issue!

You have on trigger enter? You not want OnCollisionEnter? Especially if your object is tagged.