Increase score when hit by a prefab help?

Currently i have this script:

function OnCollisionEnter(theCollision :

Collision){

	  if(theCollision.gameObject.name == "Sphere1(Clone)"){

		ScoreControl.score += 100;

		Debug.Log("Avoid the spheres!");



		

	  if(theCollision.gameObject.name == "Sphere2(Clone)"){

		ScoreControl.score += 100;

		Debug.Log("Avoid the spheres!");



		

	  if(theCollision.gameObject.name == "Sphere3(Clone)"){

		ScoreControl.score += 100;

		Debug.Log("Avoid the spheres!");



		

	  if(theCollision.gameObject.name == "Sphere4(Clone)"){

		ScoreControl.score += 100;

		Debug.Log("Avoid the spheres!");



		

	  if(theCollision.gameObject.name == "Sphere5(Clone)"){

		ScoreControl.score += 100;

		Debug.Log("Avoid the spheres!");



		

	  if(theCollision.gameObject.FindWithTag

(“bullet”)) {

		ScoreControl.score += 150;

		Debug.Log("Don't get hit!");

						}

					}

				}

			}

		}		

	}

}

The last part works fine, but i am having trouble with my sphere prefabs.

Basically, they are rigid bodies that are spawned from gameobjects and they roll down a hill, what i want to happen, is when they hit my player character, for the score to increase to the above amount 100 points, but for some reason it is not working, why is this?

I made them prefabs, even tried checking “collision detection: dynamic continuous” but every time my character gets hit by the spheres nothing happens, this is the script i have attached to the player character obviously too.

What do i need to do to make it so the score increases when im hit by the spheres?

Thanks in advance.

you are not closing your if statements in the correct place.

if(theCollision.gameObject.name == "Sphere1(Clone)"){

       ScoreControl.score += 100;

       Debug.Log("Avoid the spheres!");
}  <------- "this is an arrow"

I had this problem too, and what I did was create a separate script for scores, so in the script attached to the player you should put:

if(theCollision.gameObject.name == "Sphere2(Clone)"){    
       gameObject.Find("Score").SendMessage("ScoreUp"); //this calls the score function    
       Debug.Log("Avoid the spheres!");
}

And then you should create a different script and attach it to the score GUI, something like:

var counter : int = 0;    

function Update () {    
    guiText.text = "Score: "+counter;    
}    

function ScoreUp () {        
	counter+=100;    
}

Hope this helps!