Highscoring and changing scripts (Java/UnityScript)

I have a score system that records score in the game, but i would like to use playerprefs to check the current score and if higher that previous highscore, set the guitext to a new highscore

scoring.js

#pragma strict
var Counter : int = 0;

function addscore () {
  Counter+= 1;
  guiText.text = "score:"+Counter; 
}

function Update () {
  Debug.Log("updated Guitext.text");
  guiText.text = "Score:"+Counter;
}

function endlevel (){
  guiText.text = "0";
  Counter = 0;
}

highscore.js

#pragma strict
var High : int;

function Start () {
  guiText.text = ""+High;
}

thanks for any help

Well, update is called once a frame, if you’re using Update and your addscore function, i would ditch the guiText.text change in addscore, such a waste of time as it will be picked up on the next frame Update function call.

 #pragma strict
 var Counter : int = 0;
 
 function addscore () {
   Counter += 1;
 }
 
 function Update () {
   Debug.Log("updated Guitext.text");
   guiText.text = "Score:" + Counter.ToString();
 }
 
 function endlevel (){
   var oldHighscore : int = PlayerPrefs.GetInt("Highscore", 0); // second parameter is for default value if not found in player prefs.
   
   if (Counter > oldHighscore) {
	PlayerPrefs.SetInt("Highscore", Counter); // if the current score(counter) is greater than the old highscore, then you have beaten it.
	PlayerPrefs.Save(); // After setting, save/commit the new value(s).
   }
   
   guiText.text = "Score:0";
   Counter = 0;
 }

if you want to pull it in the other script:

#pragma strict
 var High : int;
 
 function Start () {
   High = PlayerPrefs.GetInt("Highscore", 0); // again, second parameter is default if not found yet.
   guiText.text = "Highscore:" + High.ToString();
 }