Why is player prefs not working?

Hello. I am working on a basic 2D platformer in Unity and am working on saving data. I am currently trying to save the maximum level (or the highest level they have unlocked) and also load it. Here is what I have for all of that.

static public int max_level;

static public void SaveData(string keyname,int int_to_save)


PlayerPrefs.SetInt(keyname, int_to_save);


static public void LoadData(string keyname)




The above code is what I have for data saving. It is not variable-specific. The next code will show how I am trying to save/load the max_level.

Data.SaveData("MaximumLevel", Data.max_level); //To save it.

Data.LoadData("MaximumLevel"); //To load it.

These were all in working functions that have other code in it, so I know it must be something I am doing wrong with player prefs. Any ideas on what I am doing wrong? I’ve tested in the editor and on a build.

Seems correct, PlayerPrefs.GetInt is a return type so I’m guessing you’re forgetting to set your highscore variable to it