Hi, im really new with unity and javascript and I have a Problem with my Scoring system,
whenever i get game over the score leaderboard is normal, but when I finish all stage on my game… the score from 1st to 5th is same as high score.
i dunno what i must do, here is the pict
if i get game over the score is normal
if I clared all stage in my game the score error like this
here is my script Skor.js
//static var score : int;
static var score : float = Time.timeSinceLevelLoad;
var guiScore : GUIText;
static var teks = false;
static var reset = false; // fungsi reset
static var HScore = false;
function Start()
{
//Skor dari stage lama dibawa ke stage baru
guiScore.text = "Score: " + score;
}
function LateUpdate()
{
if(teks)
{
guiScore.text = "Score: " + score;
teks = false;
}
if(reset) // mereset score ulang
{
guiScore.text = "Score: 0";
score = 0;
reset = false;
}
if(HScore)
{
if( score > PlayerPrefs.GetFloat("wormScore1"))
{
PlayerPrefs.SetFloat("wormScore5", PlayerPrefs.GetFloat("wormScore4"));
PlayerPrefs.SetFloat("wormScore4", PlayerPrefs.GetFloat("wormScore3"));
PlayerPrefs.SetFloat("wormScore3", PlayerPrefs.GetFloat("wormScore2"));
PlayerPrefs.SetFloat("wormScore2", PlayerPrefs.GetFloat("wormScore1"));
PlayerPrefs.SetFloat("wormScore1", score);
}
else if( score > PlayerPrefs.GetFloat("wormScore2"))
{
PlayerPrefs.SetFloat("wormScore5", PlayerPrefs.GetFloat("wormScore4"));
PlayerPrefs.SetFloat("wormScore4", PlayerPrefs.GetFloat("wormScore3"));
PlayerPrefs.SetFloat("wormScore3", PlayerPrefs.GetFloat("wormScore2"));
PlayerPrefs.SetFloat("wormScore2", score);
}
else if( score > PlayerPrefs.GetFloat("wormScore3"))
{
PlayerPrefs.SetFloat("wormScore5", PlayerPrefs.GetFloat("wormScore4"));
PlayerPrefs.SetFloat("wormScore4", PlayerPrefs.GetFloat("wormScore3"));
PlayerPrefs.SetFloat("wormScore3", score);
}
else if( score > PlayerPrefs.GetFloat("wormScore4"))
{
PlayerPrefs.SetFloat("wormScore5", PlayerPrefs.GetFloat("wormScore4"));
PlayerPrefs.SetFloat("wormScore4", score);
}
else if( score > PlayerPrefs.GetFloat("wormScore5"))
{
PlayerPrefs.SetFloat("wormScore5", score);
}
HScore = false;
}
}
and here is my PindahLevel.js
var guiWIN : GUIText;
var moveStage2 = false;
var moveStage3 = false;
var tamat = false;
function Update()
{
CheckForEnemies();
}
function CheckForEnemies()
{
if (moveStage2)
{
if (GameObject.FindWithTag("enemy") == null)
{
Nyawa.HITS = 0;
guiWIN.text = "STAGE 1 CLEAR";
yield WaitForSeconds(5);
Application.LoadLevel("Story2");
}
}
if (moveStage3)
{
if (GameObject.FindWithTag("enemy") == null)
{
Nyawa.HITS = 0;
guiWIN.text = "STAGE 2 CLEAR";
yield WaitForSeconds(5);
Application.LoadLevel("Story3");
}
}
if (tamat)
{
if (GameObject.FindWithTag("enemy") == null)
{
Skor.HScore = true; // This is when all stage cleared score save it.
Nyawa.HITS = 0;
guiWIN.text = "STAGE 3 CLEAR";
yield WaitForSeconds(5);
Application.LoadLevel("MenuUtama");
}
}
}
i hope anybody can help me with my problem… ![]()

