Weird thing with my script :/

heres my script :

var anything : GameObject;

var diamond : Sprite;

var circle : Sprite;

var triangle : Sprite;

var square : Sprite;

var number : int;

var target : Timer;

var AcceptInput : boolean = true;

static var score : int = 0;

var guiScore : GUIText;


function Start () {

number = Random.Range(1,4);

if(number == 1) {

anything.GetComponent(SpriteRenderer).sprite = diamond;

}

else if(number == 2) {

anything.GetComponent(SpriteRenderer).sprite = circle;

}

else if (number == 3) {

anything.GetComponent(SpriteRenderer).sprite = triangle;

}

else {

anything.GetComponent(SpriteRenderer).sprite = square;

}
}


function Update () {

if(Input.GetMouseButtonDown(0)) {

if(AcceptInput) {

AcceptInput = false;

target.enabled = true;

Debug.Log("Clicked");

if(anything.GetComponent(SpriteRenderer).sprite == diamond) {

score += 1;

guiScore.text = "Score: " + score;

StartCoroutine("YieldTestEnumerator");

number = Random.Range(1,4);

if(number == 1) {

anything.GetComponent(SpriteRenderer).sprite = diamond;

}

else if(number == 2) {

anything.GetComponent(SpriteRenderer).sprite = circle;

}

else if (number == 3) {

anything.GetComponent(SpriteRenderer).sprite = triangle;

}

else {

anything.GetComponent(SpriteRenderer).sprite = square;

}

}

if(anything.GetComponent(SpriteRenderer).sprite == circle) {

Debug.Log("Wrong Answer!");

Application.LoadLevel("GameOver");

}

if(anything.GetComponent(SpriteRenderer).sprite == triangle) {

Debug.Log("Wrong Answer!");

Application.LoadLevel("GameOver");

}

if(anything.GetComponent(SpriteRenderer).sprite == square) {

Debug.Log("Wrong Answer!");

Application.LoadLevel("GameOver");

}

if(Input.GetMouseButtonUp(0)) {
AcceptInput = true;
}
}
}
}
function YieldTestEnumerator () {
yield WaitForSeconds (0.5);
}

So basically this is a multiple choice game. Right now, if I press the button, although the sprite is diamond, it would add a point then it would load level GameOver. I don’t get this. Does anyone have any ideas? Thank you very much

I have a fair few things to point out here.

Firstly, it would be much easier to help you if you provide a little bit more information, and correctly formatted your code.

Secondly, you should look up arrays at some stage.

Finally, to answer your question, you are confused as to why it still says game over when you pick the diamond?

This is because when you get the correct answer, it is then choosing a new sprite.
You are then checking if it is an incorrect sprite.

Essentially, it is saying you got it correct, then changing it to something incorrect, then saying you got it incorrect.

Try changing your:

if (sprite is diamond)
blah

if (sprite is square)
blah

etc.

to

if (sprite is diamond)
blah

else if (sprite is square)
blah
etc.