How can I make an enemy back away from player when the player approaches?

I also wanted to add to duncan’s answer that you should also implement cone of vision for the enemies.
Something like this