[Solved] OnTriggerEnter LoadLevel only if all obj collide?

Hello, I’m no programmer and I’ve been having problems with my little noob script. I’ve never done scripting before, so I’m going to embarrass myself here by asking a really noob question. :wink:

I have a simple game where you have to get 5 different colored balls into various holes in the level. There is an invisible plane under the level that has this script attached to it. Basically if the player collides with it, it loads the game over screen. But as the script is now, if ANY one of the balls collide with it, it loads the next level.

I need to make it so it only loads the next level if ALL the balls have collided with it.

Here’s the code:

function OnTriggerEnter(other : Collider) {
	
	if (other.gameObject.name == "First Person Controller")
		Application.LoadLevel (1);
		
	if (other.gameObject.name == "Blue Ball");
		(other.gameObject.name == "Yellow Ball");
		(other.gameObject.name == "Pink Ball");
		(other.gameObject.name == "Green Ball");
		(other.gameObject.name == "Red Ball");
		
		
		Application.LoadLevel (2);
}

Okay, after some fumbling around I figured it out. I had to declare a variable (score). Every time one of the balls collides with the plane, it adds 1 to the score. If the score reaches 5 or more, then it loads the next level.

For anyone who needs it, here’s the working script!

var score = 0;


function OnTriggerEnter(other : Collider) {
	
	if (other.gameObject.name == "First Person Controller")
		Application.LoadLevel (1);


	if (other.gameObject.name == "Blue Ball")
		score += 1;
	if	(other.gameObject.name == "Yellow Ball")
		score += 1;
	if	(other.gameObject.name == "Pink Ball")
		score += 1;
	if	(other.gameObject.name == "Green Ball")
		score += 1;
	if	(other.gameObject.name == "Red Ball")
		score += 1;

		if (score >= 5 )
		Application.LoadLevel (2);
}