Help Implementing Simple Local Score Board?

I have a game that only saves one score and displays it on the main menu. Here is the code

using UnityEngine;
using System.Collections;

public class KeepingScore : MonoBehaviour {

    private GUISkin skin;
    public static int Score = 0;

    double timer = 0.0;

    void OnDestroy()

         // save highscore

                if (Score > PlayerPrefs.GetInt ("Score")) {

                       PlayerPrefs.SetInt ("Score", Score);


it is attached to the main player so when the player dies it saves the score and displays it on the main menu in a 3d text mesh object. Here is the code.

using UnityEngine;

public class MenuScript : MonoBehaviour


    private GUISkin skin;
    public TextMesh bScore;

   void Awake(){

        bScore.text = "Hi-Score: " + PlayerPrefs.GetInt("Score");   


**I was wondering how do I save multiple scores in a scoreboard like

  1. Name - 99999
  2. Name - 9999
  3. Name 99
    Maybe on a different leaderboard scene something.
    Thank you. Example scripts and instructions would be much appreciated.**

You can save multiple integers in PlayerPrefs, such as ‘score1’ through ‘score5’; You can set the name of each to – for example.

When your game ends and you need to set one of them, you can see where the new score should go. Example:

Player got score 10 this game.

// 1st place is 11
// 2nd place is 5
// 3rd place is 3

Therefore, since 10 obviously goes in the 2nd place spot, you can set 4th place to the 3rd place’s score, 3rd to the 2nd’s, and 2nd to the 10.

When your game starts, you can then grab each and display. All math is done beforehand!

What you could do is add a new GUI Label for each score. Create an array of high scores, and an array of names, and then fill it in each time a score is saved.


int[] scores;
String[] names;

void DisplayScore(int scorenum) {

   GUI.Label(Rect(0,40*scorenum, 200, 40), names[scorenum] + " - " + scores[scorenum].ToString()));


void OnGUI {

for (int i = 0; i<scores.Length; i++){ 

Completely untested, but that should, if I’ve written it right, give you a list of scores offset by 40 pixels each time with the next name and score in the row.
Hope this helps a little. If the code doesn’t work, sorry- my C# is a little rusty.