For Loops Situation

Hi guys

I am trying to retrieve each high score for each scene, but with the following code I seem to be getting the last scene’s score from 1 to 925 and not the score of the other scenes. Any ideas what I’m doing wrong? Here is the code:
using UnityEngine;

public class CompletedLevels : MonoBehaviour
{


    void Start()
    {


        int isReached = PlayerPrefs.GetInt("Level Completed");

        for (int i = 1; i <= isReached; i++)
            Debug.Log(i);



        float isScored = PlayerPrefs.GetFloat("HighScore");

        for (float j = 0; j < isScored; j++)
            Debug.Log(j);

    }

    }

Thanks for any help!

I haven’t done anything with PlayerPrefs, but it appears to be for … player preferences, like keybindings or resolution settings. Not sure it’s meant to be used for save data like your code is implying?

Beyond that, without knowing how you are actually storing the information into PlayerPrefs, we can’t really tell you why it’s not retrieving it.

My quick guesses:
When each level is completed, store the level using: PlayerPrefs.SetInt(“Level Completed”); and the high score using PlayerPrefs.SetFloat(“HighScore”);

The problem with this concept is that each level that gets completed will overwrite the previous values:

Complete level 1 with high score of 15, ‘Level Completed’ is ‘1’ and ‘HighScore’ is ‘15’

Complete level 2 with high score of 30, ‘Level Completed’ is changed to ‘2’ and ‘HighScore’ is changed to ‘30’.

‘GetInt’ and ‘GetFloat’ will return a single float, not an array.