calling a variable from a script on children?

Hey everyone. I’m very new to scripting and I am running into some trouble. I’m sure I’m doing this completely wrong. I’ve searched around a bit to find the solution to this, but I am pretty sure that I’m slaughtering the syntax or something.

Anyway- here is whats up. I have a GO with several children. These children have a script on them “collisionScript” that is returning a boolean value into a variable “hit”. I want to run through the children until the value of “hit” is returned as true at which point the parent GO will destroy itself. Here is the script on the parent where I’m sure I’m doing something wrong. Please help!

#pragma strict

function Update ()
{
	var dest : boolean = false;
	var children : Component[];
	children = GetComponentsInChildren(collisionScript);
	
	for (var child : Component in children)
	{
		if (child.hit == true)
		{
			dest = true;
		}
	}
	
	if (dest == true)
	{	
		Destroy (GameObject);
	}
}

You should declare child as collisionScript, or Unity will not know what child.hit is. Additionally, you should destroy gameObject, not GameObject (the first is the reference to the game object, while the latter is the type GameObject):

    ...
    for (var child : collisionScript in children)
    {
       if (child.hit) // no need to compare a boolean to true!
       {
         dest = true;
       }
    }

    if (dest)
    {  
       Destroy (gameObject); // gameObject, not GameObject!
    }
    ...