PlayerPrefs with if statement not working

Hi, I’m quite new to unity and I can’t figure out why this isn’t working, I’ve use a very similar code elsewhere with no issues. I am trying to set the PlayerPrefs int only if the number is higher, for example if the Playerpref is already 3(highest) then I don’t want it to change the amount to 2 or 1. The number is being set regardless of if it is higher or lower, does anyone know why or if there is a different way to code this? I’ve included part of the script because it’s pretty long, it all works except the && 2 >PlayerPrefs.GetInt(“Level1”). Any help would be much appreciated.

IEnumerator Star()
    {
        currentLevel = SceneManager.GetActiveScene().buildIndex;       
        if (lives >= 2 && lives < 4 && livesHolder.activeSelf|| lives2 >= 2 && lives2 < 4 && livesHolder2.activeSelf)
        {           
            if (currentLevel == 1 && 2 >PlayerPrefs.GetInt("Level1"))
            {

                PlayerPrefs.SetInt("level1", 2);
            }

,

PlayerPrefs are case sensitive. You are getting “Level1” and setting “level1” and that might cause your issue. Would be better to define the strings like public const string LEVEL1 = "Level1"; (if they are globally used and constant values). then you can use it like PlayerPrefs.SetInt(LEVEL1, 2); That way you can avoid these typo errors.

PS. const is static in nature so you can call it from other classes via [LevelClassName].LEVEL1