Attempt counter reset when click retry scene
I have a script that shows on the screen the number of attempts the player makes to win each scene. When he loses the scene by clicking retry he reloads the scene and can try again. I'd like to show the number of attempts the player had on the screen. But every time you click retry resets the counter.
public class Attempts : MonoBehaviour {
private int attempts;
private int var;
public Text attemptsText;
public void ContadorDeTentativas()
{
if (attempts == 0)
{
attempts++;
attemptsText.text = ("Attempts: " + attempts);
PlayerPrefs.SetInt("Total", attempts);
}
else
{
var = PlayerPrefs.GetInt("Total") + 1;
attemptsText.text = ("Attempts: " + var);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to Reset Save Data 1 Answer
How do I get a "counter" to reset back to "0" 2 Answers
How can i reset the count down timer when my player collides with an object 2 Answers
How to initiate a counter when the script runs once it increments and once called, increments again? 0 Answers
Best way to save and load data for each level in 2D game? 0 Answers