If statement fails...
Hi,
I can't find the reason why the first if statement gets executed when I am loading another scene. Even though I am making sure that game1done is true, and checker is !=17, the if() is still being executed a second time, when the user press a button doing a Loadlevel()
Any ideas? Thanks
if ( game1done == false && checker == 17){
checker = 24;
Debug.Log("setting 11 CALLED");
Debug.Log ("game 1 is " + game1done);
Debug.Log ("game 2 is " + game2done);
timeLeft = timerTime;
Debug.Log ("start game 2");
//give one star and save it
//Set pref 11
PlayerPrefs.SetInt (theday, 11);
star1.sprite = StarGet;
game1done = true;
}
else if (game1done == true && game2done == false ) {
PlayerPrefs.SetInt (theday, 12);
int dayValueB = PlayerPrefs.GetInt (theday);
Debug.Log ("DayValue of"+ theday + "is : " + dayValueB);
game1done = true;
game2done = true;
//button game 3
//GameObject button3 = GameObject.Find ("game3");
//ExecuteEvents.Execute (button3.gameObject, pointer, ExecuteEvents.pointerClickHandler);
timeLeft = timerTime;
Debug.Log ("start game 3");
Debug.Log ("game 1 is " + game1done);
Debug.Log ("game 2 is " + game2done);
//only happens when the game 2 is done...
star2.sprite = StarGet;
}
Could you maybe edit your question to show the entire script?
As @Light said, we need to see where and when you are setting those variables and when you make the if-check so we can try to guess why the variables have different values from what you think they have :)
@Nose$$anonymous$$ills Thanks for expressing this more clearly :)
did you check in the inspector if the variables changed cause it's impossible to get executed if the variables didn't changed give FULL script
Your answer
![](https://koobas.hobune.stream/wayback/20220612063129im_/https://answers.unity.com/themes/thub/images/avi.jpg)