PlayerPrefs not quite working

So i’m trying to make an experience system using PlayerPrefs right now. Previously I had a working
script like that that saved the player’s position. But later i started this level system, and I accidentally mistaked the position script with the level script and deleted it and it stopped working. I’ve been
trying to finally make it work for like 8 hours (maybe 2 per day) and yet still doesn’t work. There are no errors and after restarting the game the value doesn’t load onto it’s previous state.

using System.Collections;

using UnityEngine.UI;

using UnityEngine;

public class PPLS : MonoBehaviour
{

public int lp;

public Text lvltext;

public int Level;

void Update()
		{
	PlayerPrefs.SetInt(Level.ToString(), lp);
	Level = lp;

	PlayerPrefs.GetInt(Level.ToString());
 	lvltext.text = Level.ToString();
		}

}

If i made grammar mistakes then sorry, i don’t speak english. If there any questions about the script
i’ll try to answer. If anyone has made this working then please send the whole script or there is only one error, then the broken line. Thanks

Hey!
I don’t really get what you’re trying to do…

For Example :
lp = 2;
Level = 1;

Then :

You are Setting the Playerprefs int named “1” to 2.
Then you are setting Level from 1 to 2.
The next line should do nothing (?). You are looking for the Playerprefs “2” and then you are doing nothing with it.
and then you are setting the text to 2.

Maybe I got it wrong…
But sometimes you just need someone to tell you where you got the logic error. I think everybody has that sometimes. :slight_smile:

PlayerPrefs is not the correct way to do this… unless you want players to be able to change their experience (and anything else you put in the player preferences). You should consider persisting data between scenes or using data serialization to persist data between game sessions.
_