Adding game objects to array?

Ok so I have an array of pathnodes, I need to select all of the pathnodes with the a specific zone ID and add them to the LocalPathNodeAR. But whenever I run the game it keeps giving me a null reference exception. I’m pretty sure its something to do with the LocalPathNodAR because thats where the debugging logs stop. Anyway heres the code, I hope someone can help me out here :face_with_spiral_eyes:

var TEST;
static var PathTarget:GameObject;
public var AssignedZoneID:int;

var WorldPathNodeAR:GameObject[];

function Start () {
	WorldPathNodeAR = GameObject.FindGameObjectsWithTag("PathNode"); 
	FindPaths();
}

function FindPaths () {
	
	var LocalPathNodeAR:GameObject[];	
	for(var g:GameObject in WorldPathNodeAR)
		{
		Debug.Log(WorldPathNodeAR.Length);
		var pathNodeScript = g.GetComponent(PathNodeSetup);
		if(pathNodeScript.PathZoneID == AssignedZoneID)
			{ 
			LocalPathNodeAR.Push(g);	
			}
		}
	Debug.Log(LocalPathNodeAR.Length);
	var MyIndex = Random.Range(0,(LocalPathNodeAR.length - 1));
	PathTarget = LocalPathNodeAR[MyIndex];
	Debug.Log(LocalPathNodeAR);		 	 
}
 
function Update () {
	this.GetComponent(NavMeshAgent).destination = PathTarget.transform.position; 
	var navmeshAgent = this.GetComponent(NavMeshAgent);
	if(navmeshAgent.remainingDistance == 0)
	{
	FindPaths();
	}
}

The builtin arrays don’t have functions like “push”. In order to change them dynamically you have to create a new one with an extra element, copy the contents of the original along with the new element and then make this new array the original.

Findgameobjectswithtag returns a list,mso why not use a list. Besides, lists are able to ad and remove objects dynamically. Arrays can not.