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(){
	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)){
		}else if (GUI.Button(Rect (screenX/4 , screenY/2, screenX/10, screenY/10),menuIcon, style)){

function win(){
	didWin = true;

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


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