AddExplosoionForce; alternative to hit.rigidbody

Hi Guys,
I am just trying to apply an AddExplosionForce() to an object. I copied the code direct from the reference matierials.

But I am getting an error saying hit.rigidbody, rigidbody is not a member of Collider. Ok, but then what do I do, and why is this in the reference material?

Unity’s Code

var radius = 5.0;
var power = 10.0;
function Start () {
    // Applies an explosion force to all nearby rigidbodies
    var explosionPos : Vector3 = transform.position;
    var colliders : Collider[] = Physics.OverlapSphere (explosionPos, radius);
    
    for (var hit : Collider in colliders) {
        if (!hit)
            continue;
        
        if (hit.rigidbody)
            hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
    }
}

My Code

function blowUpGrenade()
{
	print("+++++++++blowing up greande++++++++++++++");
    var radius = 5.0;
	var power = 10.0;
    var explosionPos : Vector3 = transform.position;
    var colliders : Collider[] = Physics.OverlapSphere (explosionPos, radius);
    
    for (var hit : Collider in colliders) 
    {
    	if (!hit)
    	{
    		print("!hit");
    		continue;
   	 	}
    
    	if (hit.rigidbody)
    	{
    		hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
    		print("hit.rigidbody " + hit.rigidBody);
    	}    
	}
}

The error occurs on line 19.

Anyone? Why would rigidbody not be a member of hit?

Whats the name of your script? is it “hit” by chance, or do you have a .js script named hit? If you do, name it differently.

The issue would be overriding Collider, not ‘hit’. If you have any class or file named Collider you’ll need to change its name.

If that’s not the case, try hit.gameObject.rigidbody.

in any case you should avoid using reserved words for your scripts or variables