Why doesn't my highscore script work?

I’m making a little endless runner game where the camera follows a moving character. I managed to make the score gui work but for some reason my highscore gui doesn’t keep track of the highest score and just displays 0 all the time. I’m new to coding but have some experience with how unity works, I feel like i’m just overlooking something very simple but haven’t been able to find answers online.
Here is my code for managing the score/highscore:

using UnityEngine;
using System.Collections;

public class NewScore : MonoBehaviour {
	
	static int score = 0;
	static int highScore = 0;
static public void AddPoint() {
if(score > highScore) {
			highScore = score;
		}
	}
void Start() {
score = 0;
		highScore = PlayerPrefs.GetInt("highScore", 0);
	}
	
	void OnDisable() {
PlayerPrefs.SetInt("highScore", highScore);
		PlayerPrefs.SetInt ("score", score);
	}
	
	void Update () {
		guiText.text = "Score: " + score + "

High Score: " + highScore;
PlayerPrefs.SetInt (“highScore”, highScore);
}

	public void IncreaseScore(float amount)
	{
		score += (int)amount;
	}
}

I think that it’s because GetInt taking only one argument - value name. If it isn’t solution you should use Debug.Log to see what’s wrong.

I would put this line:
PlayerPrefs.SetInt (“highScore”, highScore);
After the ‘score += (int)amount’ in IncreaseScore.
That way your save data of the high score will only be saved when it’s increasing. Not every tick, like you’re doing now :wink:

To help your problem:
Add ‘using UnityEngine.UI’ on top of you file.
Next place a ‘Text’ Variable under the line static int highscore.
(example: ‘public Text ScoreText;’ )

Then you can drag the text object from the editor into the text slot on your gameobject with this script :slight_smile:

Oh wow… I just answered my own question lol… I cut

if(score > highScore) {
             highScore = score;

from the AddPoint function and pasted it into the IncreaseScore function and now my highscore works properly! thanks everyone for their help though, helped me look more closely at my code.