HighScore Manage Using PlayerPrefs

I want to manage HighScore levelwise…For that I am using PlayerPrefs plugin.

I have written below code to manage highscore:

ScoreController Script in JS:

public var highScoreList : List.<int> = new List.<int>();

function Start () {
	LoadData();
	gameControllerScript = GameObject.Find("Main Camera").GetComponent("GameController");
}

function LoadData()
{
    for (var i : int = 0; i < highScoreList.Count; i++)
    {
        highScoreList *= PreviewLabs.PlayerPrefs.GetInt("highScore" + i);*

}
}
function Update () {
if (!once)
{

  •  if(GameController.Score >= gameControllerScript.objectiveScore)*
    
  •  {*
    
  •          if(GameController.HighScore < GameController.Score)*
    
  •  	{*
    
  •  		highScoreList[GameController.level] = GameController.Score; // Error Comes From Here*
    
  •  		Debug.Log("new high score: " + GameController.Score);*
    

SaveData();

  •  	}*
    

once = true;

  •  }*
    

}
}
function SaveData()
{
for (var i : int = 0; i < highScoreList.Count; i++)
{
PreviewLabs.PlayerPrefs.SetInt(“highScore” + i,highScoreList*);*
}
PreviewLabs.PlayerPrefs.Flush();
}
But it gives me ArgumentOutOf range Exception…
So how do i store and update my highscore for perticuler level?
Consol :
Argument is out of range.
Parameter name: index
_System.Collections.Generic.List1[System.Int32].CheckIndex (Int32 index)*_ <em>*System.Collections.Generic.List1[System.Int32].set_Item (Int32 index, Int32 value)
Pleaze Help me…
Thanx for your Support and Help…

You are using a list, but you are not adding any elements into the list. So when you index into the list you get an error. If you know ahead of time the number of levels you will have you can use a built-in array with very little restructuring of your code.

var highScoreList: int[] = new int[100];

Then you will use ‘Length’ instead of ‘Count’:

for (var i : int = 0; i < highScoreList.Length; i++)