How to remove GameObject from List?

In one script (JS) I have this code:

static var newBall: GameObject;
static var ballPool = new List.<GameObject>();	
function MakeBallPool ()
{	
	
	for (var n = 0; n < 200; n++)
	{
		var newBall: GameObject;
		newBall = Instantiate(ballPrefab, transform.position, transform.rotation);
		newBall.SetActive(false);
		ballPool.Add(newBall);
	}	
}

Then on my other script I am trying (being the operative word) to get the balls from this “pool” into my using list. Here is the code:

var listBalls = new List.<GameObject>();	

function drawBalls ()
{
	var x: float;
	var	y: float;
	
	if (existsBalls == false)
	{
		x = Random.value * 100 - 50;
		y = Random.value * 100 - 50;
		Manager.ballPool.Remove(Manager.newBall);
		Manager.newBall.transform.parent = this.transform;
		Manager.newBall.transform.localPosition = Vector3(x, y, 0);
		Manager.newBall.SetActive(true);
		listBalls.Add(Manager.newBall);
	}
	existsBalls = true;
	}
}

Now first of all I realise I was a complete spanner and daft to be wondering why I kept getting the same ball due to the static. But the question is how do I get this to pass across properly? Any help would be really appreciated I have trawled through everywhere and know I am missing the obvious.

How do you expect the newBall variable to be updated? It is never assigned to, except during the intialization loop. So your first Remove() will work, but any consecutive call would try to remove newBall again, since it still contains the same object.

A quickfix would be to add something like this to your Manager:

function SelectNewBall(){
    // update newBall variable ...
    newBall=listBalls[listBalls.Count-1]; // ...with the last ball in the pool
}

Then call this method before your Remove() line.