Can anyone tell me what is wrong with my high score displaying script?

My HIGH SCORE stuck at “0”.

  using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    
    public class ScoreController : MonoBehaviour {
    
    	public Text ScoreText;
    	public int score;
    	private int Count = 2;
    	public Text TotalScoreText;
    	public Text HighScoreText;
    	public int HighScore;
    
    
    	void Start () {
    		
    		score = 0;
    		UpdateScore ();
    
    		if(score>PlayerPrefs.GetInt ("HIGHSCORE_KEY",0))
    		{
    			PlayerPrefs.SetInt ("HIGHSCORE_KEY",score);
    		}
    		
    
    			
    			HighScore = PlayerPrefs.GetInt ("HIGHSCORE_KEY",0);
    		
    		
    
    	
    	}
    	
    
    	public	void UpdateScore() {
    		
    		ScoreText.text = "Score: " + score;
    		TotalScoreText.text = "TOTAL SCORE -: " + score;
    		HighScoreText.text = "HIGH SCORE -: " + HighScore; 
    	}
    	
    	public void AddScore( )
    	{
    		
    		score += Count;
    		UpdateScore ();
    		
    	}
    
    
    }

Hi,
In start function u have assigned the assigning the score=0 and then called UpdateScore ().Then the value of score remains same as zero it does not get updated.

So the PlayerPrefs of “HIGHSCORE_KEY” value remains zero.

U have missed to call the function for adding score.

After updating score,“HIGHSCORE_KEY” PlayerPrefs value has to assign to HighScore.

check with the code its updating.

void Start () 
	{
		score = 0;
		UpdateScore ();
		AddScore ();		
	}
		
	public    void UpdateScore() 
	{
		ScoreText.text = "Score: " + score;
		TotalScoreText.text = "TOTAL SCORE -: " + score;
		HighScoreText.text = "HIGH SCORE -: " + HighScore; 
	}
	
	public void AddScore( )
	{
		score += Count;
		if(score>PlayerPrefs.GetInt ("HIGHSCORE_KEY",0))
		{
			PlayerPrefs.SetInt ("HIGHSCORE_KEY",score);
		}
		HighScore = PlayerPrefs.GetInt ("HIGHSCORE_KEY",0);
		UpdateScore ();
	}

You’re only checking if score is higher than score in start, try moving it into the AddScore(). This isn’t the most efficient way of handling a high score, you would want to check it at the end of the game but I assume your code is just temporary testing.

public void UpdateScore() {
             
    if(score>PlayerPrefs.GetInt ("HIGHSCORE_KEY",0))
    {
        PlayerPrefs.SetInt ("HIGHSCORE_KEY",score);
    }
                 
    HighScore = PlayerPrefs.GetInt ("HIGHSCORE_KEY",0);

    ScoreText.text = "Score: " + score;
    TotalScoreText.text = "TOTAL SCORE -: " + score;
    HighScoreText.text = "HIGH SCORE -: " + HighScore;          

}

You are never setting HIGHSCORE_KEY after you add you call AddScore, I would add this to the end of your UpdateScore function.

HighScore = PlayerPrefs.GetInt ("HIGHSCORE_KEY",0);
if(score > HighScore)
{
    PlayerPrefs.SetInt("HIGHSCORE_KEY", score);
}