EnemyAI that find multiple gameobjects by tag

Hello, I have a script where a enemy must choose the closest player. It works with a single player but not with multiple players. I have more code but I only show you the necessary because if not it would be very long. I used a code that calculates which is the closest player (bestTarget), and the enemy should find him. The error: EnemyController.cs(35,25): error CS1501: No overload for method GetClosestPlayer' takes 0’ arguments
Thanks in advance :slight_smile:

void Awake ()
{
nav = GetComponent ();
bestTarget = player = GameObject.FindWithTag (β€œPlayer”).transform;

}
void Update ()
{
	if(!isDead)
	{
		GetClosestPlayer ();
		nav.SetDestination (player.position);
		controller.SetFloat ("speed", Mathf.Abs(nav.velocity.x) + Mathf.Abs (nav.velocity.z));
		float distance = Vector3.Distance(transform.position, player.position);
		if(distance < 3)
		{
			attackTimer += Time.deltaTime;
		}
		else if (attackTimer > 0)
		{
			attackTimer -= Time.deltaTime*2;
		}
		else
			attackTimer = 0;
	}
}

Transform GetClosestPlayer(Transform[]players)
{
	float closestDistanceSqr = Mathf.Infinity;
	Vector3 currentPosition = transform.position;
	foreach (Transform potentialTarget in players) 
	{
		Vector3 directionToTarget = potentialTarget.position - currentPosition;
		float dSqrToTarget = directionToTarget.sqrMagnitude;
		if(dSqrToTarget < closestDistanceSqr)
		{
		closestDistanceSqr = dSqrToTarget;
		bestTarget = potentialTarget;
		}
	}
	return bestTarget;
}

Does it work???
Some errors I found in yout code:

1 - GameObject.FindWithTag only returns 1 object, for an array use FindGameObjectsWithTag

2 - Calling GetClosestPlayer (); you are not transmiting any parameter, where is the array?

3 - GetClosestPlayer(Transformplayers) returns a Transform, what are you doing with the returned variable?