Local highscore issues

Hello,
I’m here, once again, to ask for help.

I’m working on a local highscore for a game that I’m working on, but after spending the last few hours searching for a good solution, without any luck, i decided to ask.

The curent code that i got for the highscore script is the following:

//Linking the text that needs to show the highscore
public Text highscore;


//If the score is better than the old highscore it needs to be replaced
		if (score > PlayerPrefs.GetInt ("highscore")) {
			PlayerPrefs.SetInt ("highscore", score);
		}


// Get the highscore
highscore = PlayerPrefs.GetInt ("highscore");

//Set the text of the text.
highscore.text = "Highscore: " + highscore;

My issue is:

Cannot implicitly convert type ‘int’ to ‘UnityEngine.UI.Text’

And it leads to this line with the error:
highscore = PlayerPrefs.GetInt (“highscore”);

Is there any way to solve this issue, or maybe another way to make a local highscore?

Thanks.

Regards.
Tech.

My full code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class EndGameScore : MonoBehaviour {

	public Text Finalscore;
	public Text highscore;
	  
	int score = 0;
	
	// Use this for initialization
	void Start () {
		
		if (score > PlayerPrefs.GetInt ("highscore")) {
			PlayerPrefs.SetInt ("highscore", score);
		}
				highscore = PlayerPrefs.GetInt ("highscore");
				score = PlayerPrefs.GetInt ("Score");
				Finalscore.text = "Your score: " + score;
				highscore.text = "Highscore: " + highscore;
					
		}

highscore is of type Text and GetInt from PlayerPrefs returns an int. You need to transform the type.

 //Linking the text that needs to show the highscore
public Text highscore;
//If the score is better than the old highscore it needs to be replaced
if (score > PlayerPrefs.GetInt ("highscore")) {
  PlayerPrefs.SetInt ("highscore", score);
}
// Get the highscore
// Set the text of the text.
  highscore.text = "Highscore: " + PlayerPrefs.GetInt("highscore").ToString();

EDIT:

Using your code, i’d probably modify it to do the following:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class EndGameScore : MonoBehaviour {
	
	public Text Finalscore;
	public Text highscore;
	int score = 0;
	int oldHighScore = 0;
	
	// Use this for initialization
	void Start () {
		oldHighScore = PlayerPrefs.GetInt ("highscore"); // You're already going to call this multiple times it seems, might as well stuff it in a variable.
		score = PlayerPrefs.GetInt ("Score");
		
		if (score > oldHighScore) {
			PlayerPrefs.SetInt ("highscore", score);
			PlayerPrefs.Save();
		}
		
		Finalscore.text = "Your score: " + score;
		highscore.text = "Highscore: " + (score > oldHighScore ? score : oldHighScore);
	}
}

The part that you see setting the highscore.text is a ternary operator, it’s short hand for a if/else statement, in the case above, if score is greater than oldHighScore, then use the value from score if not, use oldHighScore since it is still the king.