Tower wont switch target

using UnityEngine;
using System.Collections;

public class cannonTurret : MonoBehaviour {
    [SerializeField]
    public GameObject cannonBall;
    public float distance = 3.0f;
    public float secondsBetweenShots = 2.0f;
    private Transform targetEnemy;
    private float timeStamp = 0.0f;
 
 
    void Fire() {
       Instantiate(cannonBall, transform.position, transform.rotation);
    }
 
    void Update () {
		//targetEnemy = GameObject.FindGameObjectWithTag("Enemy").transform;
		if(targetEnemy != null)
		{	
       		 if (Time.time >= timeStamp  (targetEnemy.position - transform.position).magnitude < distance) 
			 {
	           	 Fire();
	        	 timeStamp = Time.time + secondsBetweenShots;
			 }
		}
    }
	
	void OnTriggerEnter(Collider collider)
	{
		if(collider.gameObject.tag == "Enemy")
		{
			//targetEnemy = GameObject.FindGameObjectWithTag("Enemy").transform;
			Fire ();
		}
	}
	
	void OnTriggerExit()
	{
		if(collider.gameObject.tag == "Enemy")
		{
			//targetEnemy = GameObject.FindGameObjectWithTag("Enemy").transform;
			//targetEnemy = null;
			//Fire ();
			
		}
	}
}

It just wont and I replaced and expanded the sphere collider.

One, have it find closest, two, make it find closest when the current target is out of range.

Vector.distance…

Pick Closest one…
Also, make sure your collier is marked as a trigger.

You also may want to store all the targets in a list as they enter and exit.
So, your script is aware of all the potential targets.

Then, you could also do smarter stuff to make advanced towers.
Like check the health of all the targets in range and shot at the one with the lowest health… better kill rate.