my script not working

// question1
if(question1==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture1);

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture01))

{
question1=false;
score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question1”));

}

}

this is my script and if i press GUI button a pop up message or text to display and i tired many methods it didn’t workout someone help me to solve this …

Not sure to understand what you are trying to achieve …

Can you explain what behavior you are trying to reach?
Also, you should format your code and use the code format to see it correctly

// question1
if(question1){ // if true, you don't need to make it == True
     GUI.DrawTexture(new Rect(400,40,200,100),texture1);
     
     if( GUI.Button( new Rect(150, 200, 200, 100),texture01)){
          question1=false;
          score+=5;
          questionsfound+=1;
          Destroy(GameObject.Find("question1"));
     }
}

Also it seems you have an error, you have one “{” that has no reason to be here after the draw texture …

thanks for ur reply…trying to create quiz type of game if u click on the button popup should appear like correct answer …only this part of script is not working

this is script 1

var question1:boolean=false;
var question2:boolean=false;
var question3:boolean=false;
var question4:boolean=false;
var question5:boolean=false;
var question6:boolean=false;
var question7:boolean=false;
var question8:boolean=false;
var question9:boolean=false;
var question10:boolean=false;

var texture1: Texture;
var texture2: Texture;
var texture3: Texture;
var texture4: Texture;
var texture5: Texture;
var texture6: Texture;
var texture7: Texture;
var texture8: Texture;
var texture9: Texture;
var texture10: Texture;
var texture11: Texture;

var texture01: Texture;
var texture02: Texture;
var texture03: Texture;
var texture04: Texture;
var texture05: Texture;
var texture06: Texture;
var texture07: Texture;
var texture08: Texture;
var texture09: Texture;
var texture010: Texture;
var texture011: Texture;
var texture012: Texture;
var texture013: Texture;
var texture014: Texture;
var texture015: Texture;
var texture016: Texture;
var texture017: Texture;
var texture018: Texture;
var texture019: Texture;
var texture020: Texture;

var questionsfound=0;

var score=0;

function OnGUI()
{

// question1
if(question1){

GUI.DrawTexture(new Rect(400,40,200,100),texture1);

ruledis();

if( GUI.Button( new Rect(150, 200, 200, 100),texture01))

{

question1=false;

score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question1”));

}

if( GUI.Button( new Rect(600, 200, 200, 100),texture02))

{

score+=-5;
questionsfound+=1;

Destroy(GameObject.Find(“question1”));
}

}

// question2
if(question2==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture2);
ruledis();

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture03))

{
question2=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question2”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture04))

{
question2=false;
score+=5;
questionsfound+=1;
Destroy(GameObject.Find(“question2”));
}
}

//question3

if(question3==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture3);

ruledis();

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture05))

{
question3=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question3”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture06))

{
question3=false;
score+=5;

questionsfound+=1;
Destroy(GameObject.Find(“question3”));
}

}

//question4
if(question4==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture4);

ruledis();

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture07))

{
question4=false;
score+=5;
questionsfound+=1;
Destroy(GameObject.Find(“question4”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture08))

{
question4=false;
score+=-5;
questionsfound+=1;

Destroy(GameObject.Find(“question4”));
}

}

//question5
if(question5==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture5);
ruledis();

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture09))

{
question5=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question5”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture010))

{
question5=false;
score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question5”));
}

}

//queston6

if(question6==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture6);

ruledis();
{
if( GUI.Button( new Rect(150, 200, 200, 100),texture011))

{
question6=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question6”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture012))

{
question6=false;
score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question6”));
}

}
if(question7==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture7);
ruledis();

{

if( GUI.Button( new Rect(150, 200, 200, 100),texture013))

{
question7=false;
score+=5;
questionsfound+=1;
Destroy(GameObject.Find(“question7”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture014))

{
question7=false;
score+=-5;
questionsfound+=1;

Destroy(GameObject.Find(“question7”));
}

}
if(question8==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture8);
ruledis();
{

if( GUI.Button( new Rect(150, 200, 200, 100),texture015))

{
question8=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question8”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture016))

{
question8=false;
score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question8”));
}

}
if(question9==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture9);
ruledis();
{

if( GUI.Button( new Rect(150, 200, 200, 100),texture017))

{
question9=false;
score+=5;
questionsfound+=1;
Destroy(GameObject.Find(“question9”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture018))

{
question9=false;
score+=-5;
questionsfound+=1;

Destroy(GameObject.Find(“question9”));
}

}
if(question10==true)

{

GUI.DrawTexture(new Rect(400,40,200,100),texture10);
ruledis();

{
if( GUI.Button( new Rect(150, 200, 200, 100),texture019))

{
question10=false;
score+=-5;
questionsfound+=1;
Destroy(GameObject.Find(“question10”));
}
}

if( GUI.Button( new Rect(600, 200, 200, 100),texture020))

{
question10=false;
score+=5;
questionsfound+=1;

Destroy(GameObject.Find(“question10”));

}

}

GUI.Box(new Rect(500,10,100,20),"SCORE= " +score.ToString(“0”));

GUI.Box(new Rect(700,10,200,20),“QUESTIONS FOUND= 10/” +questionsfound.ToString(“0”));

}

function ruledis()
{
yield WaitForSeconds(10);
question1=false;
question2=false;
question3=false;
question4=false;
question5=false;
question6=false;
question7=false;
question8=false;
question9=false;
question10=false;

}
script associated to this script 2

private var question : QUESTIONMANAGER;
var collectSound:AudioClip;
function Start()
{
question = GameObject.Find(“Player”).GetComponent(“QUESTIONMANAGER”);
}

function OnTriggerEnter(collider:Collider)
{
if(collider.tag==“Player”)

{

AudioSource.PlayClipAtPoint(collectSound, transform.position);
question.question1=true;
question.question2=false;
question.question3=false;
question.question4=false;
question.question5=false;
question.question6=false;
question.question7=false;
question.question8=false;
question.question9=false;
question.question10=false;

}
}

Well… Format your code first, that will help others.
From what I see, you should probably use loop feature to optimize your code, it will also help you understand more what you are creating.

You can use Array or List and add in the inspectors your textures, etc.
And access them using for loop.

i will correct in future becos i am new to coding and unity …everything works well in this code but when i press gui button nothing pops out…