Hightscore??? Please Help

Here is a code. I have two GUIText. 1st Points, 2st Hightscore.

how i get the hightscore.

Can you please complete the code for me?

Thanks :slight_smile:


var target : Transform;
private var myTransform : Transform;
var currentDistance : String = “”;

var score : GUIText;
var hightScore : GUIText;

function Start () {
myTransform = transform;
}

function Update () {
var distance = (target.position - myTransform.position).magnitude;
currentDistance = distance.ToString(“F0”);
score.text = "Punkte: " + currentDistance;
}

http://forum.unity3d.com/threads/143875-Using-code-tags-properly
You’ll want to have a variable to store the actual score and just update the GUIText. As for your highscore, it can be something you retrieve from playerprefs and just update that in Start.

var myScore : int;
var score : GUIText;
var highScore : GUIText;

function Start()
{
    highScore.text = PlayerPrefs.GetInt("highscore").ToString(); // I use GetInt because your score is usually an integer value.
}

function Update()
{
    score.text = myScore.ToString();
}