Problem with selective aggro

My friends and I are trying to make a game prototype in which an AI follows/attacks the player if the player is within a certain distance of the enemy AI. We cannot get aggro to work at a distance. If we try, the AI simply follows the player the moment the game starts, regardless of X and Y coordinates. We’ve been trying to get this to work for over a week. To do this we have been modifying the basic AI tank example in gdevelop, for reference.