The we need 2 consecutive actions, that you want to execute every time you need the player to switch target. It could be every 1 second, but maybe don't check this every tick, it could cost a lot if you have a high number of enemies.
First action will check all enemies, and set a variable to remember what enemy is the closest. Let's call "EnemyID" (set to 0) and "EnemyDistance" (set to 1000000 to make this easier) the 2 variables :
- For each object Y // we want to do this test for every enemy
- EnemyDistance > distance(ObjectY,Player) // if the enemy we are checking is closer to the player than another before
This will trigger a simple action that will set both variables, EnemyID to objectY.ID, and EnemyDistance to distance(objectY,Player).
Once this loop is done, the variable "EnemyID" is set to the ID of the enemy that is the closest to the player. You can create a second action, that will select the enemy by it's ID using the variable, and ask the player to take it as target.