Blender Game Engine - How i can make my turrets aim the enemy that’s closest to the village?
I believe that your question has already been posted and answered on blenderartists here

.blend file here

======================================================================

Additional info:

Q: 


  what’s the difference module vs script in the logic bricks??


A:


  script is for 1 object to use, module can be used by multiple objects, so instead of 1 tower you could connect 100 to it.


#Logick Bricks : (Always -&gt; Python-Module track_to_closest.track -&gt; Edit object - Track_to)
# and a property "track_distance" on the object using this script
# and place a property on the objects you want to track to: called track_to


def track(cont):

    own         = cont.owner
    scene       = own.scene    
    track_to    = cont.actuators['track_to']

    ai = [obj for obj in scene.objects if 'track_to' in obj]

    if ai:

        closest_ai      = sorted(ai, key=lambda enemy: own.getDistanceTo(enemy))[0]    
        distance        = own.getDistanceTo(closest_ai) 
        max_distance    = own['track_distance'] 

        if distance &lt;= max_distance:

            track_to.object = closest_ai
            cont.activate(track_to)

        else:
            cont.deactivate(track_to)