Add objects within a certain distance into an array

i need to add all objects into an array that are within a certain distance. i have the script;

var inRange : GameObject[];

function Awake () {
	inRange = 
}

and in the part

	inRange =

I need to declare that the objects within that range belong in that array

You can use OverlapSphere() if all of your objects have colliders attached.

var inRange : GameObject[];
function Awake(){
var colliders : Collider[] = Physics.OverlapSphere(transform.position,distance);
inRange = new GameObject[colliders.Length];
for(var i=0;i<colliders.Length;i++){
     inRange[i] = colliders[i].gameObject;
}
}

and how am i supposed to use this? It gives me an error
Assets/explosion.js(6,23): BCE0024: The type ‘UnityEngine.GameObject’ does not have a visible constructor that matches the argument list ‘(int)’.

Just a typo, change:

inRange = new GameObject(colliders.Length);

to:

inRange = new GameObject[colliders.Length];

you could also do it very similarly to the solution I gave you in your other thread:

var allObjects = FindObjectsOfType(GameObject);
for (var go : GameObject in allObjects) {
	var distanceToMe : float = Vector3.Distance(transform.position, go.transform.position);
	if(distanceToMe < range)
		//add to array here
}

But overlapsphere is probably more efficient. If you’re trying to do an explosion, you should check out the explosion script in the fps tutorial on unity3d.com, it’s pretty useful, because it covers things like applying explosion forces, mathematically varying damage amount based on distance to explosion center, and applying physics to dead replacement objects in the event that the explosion reduces an enemy’s health to zero.