Don't use expressions like distance(Player.X, Player.Y, Enemy.X, Enemy.Y) without picking the enemy first!
And you don't need distance() at all if you have "Line of sight" behavior. Just configure its settings correctly:
You can also add several "Line of sight" behaviors to Player sprite with different settings. For example one for detecting enemies at short distance, another for long distance, another that ignores obstacles etc.