So will make a Highscore, but it don´t works.
Can you complete the code for me?
I have no idea what i will make.
Thanks for every help ![]()
var target : Transform;
private var myTransform : Transform;
var currentDistance : String = “”;
var score : GUIText;
var highScore : GUIText;
var bestScore : float = 0;
function Start () {
myTransform = transform;
if (PlayerPrefs.HasKey(“Hightscoreab”)){
bestScore = PlayerPrefs.GetFloat(“Hightscoreab”);
}
}
function Update () {
var distance = (target.position - myTransform.position).magnitude;
currentDistance = distance.ToString(“F0”);
score.text = "Punkte: " + currentDistance;
if (bestScore <= score) { /////here is a bug say unity
PlayerPrefs.SetFloat(“Hightscoreab”, score)(); ////here is a bug say unity
}
}
////maybe are more bugs, thank you for every help