Multiple turrets select their own target

I just noticed all the turrets attempt to face the same target. I have multiple units being generated. Say I have multiple turrets, how would I have each turret select its own target, say closest target to it?

You could loop (for each turret) through all your turrets every few logic ticks and find the nearest enemy (pick nearest object: enemy) that has a certain “distance between two objects” (enemy-turret). Link the enemy to the tower and let the tower attack it. If the “distance between two objects” gets too far and there is another enemy near the tower break the link and create a new one for the new enemy.