Variables values are not changing?

Hello, I am trying to make a puzzle game and I have a small little text to display when the use wins.
This first script is called WinScreen.js.

#pragma strict
private var screenX = Screen.width; 
private var screenY = Screen.height;
var style:GUIStyle;
private var didWin = false;


var nextIcon:Texture;
var menuIcon:Texture;


function Start () {
	
}

function Update () {
	
}

function OnGUI(){
	Debug.Log(didWin);
	if (didWin){
	
		GUI.Label(Rect(0,0,screenX, screenY), "WIN", style); 
		
		if (GUI.Button(Rect (screenX/1.5 , screenY/2 , screenX/10, screenY/10),nextIcon, style)){
			Application.LoadLevel(Application.loadedLevel+1);
		}else if (GUI.Button(Rect (screenX/4 , screenY/2, screenX/10, screenY/10),menuIcon, style)){
			Application.LoadLevel("scene0");
		}
		
		
		
	}
}

function win(){
	
	didWin = true;
	Debug.Log(didWin);
}

from another script attached to the same gameObject, I have:

gameObject.GetComponent(WinScreen).win();

Sometimes, this script works, and a win screen is displayed. Other times however, it seems that changing the didWin variable to true does nothing and it stays false and no win screen is displayed.

How can I fix this?

I am having the same issue, I believe that it is something to do this the “else if” statement.

I have also the same type of project that is lilylisto. I want to show the happy birthday sister when system date will match sister birthday date so what’s the script I have to write to show this on game dashboard