How to make player stop a certain distance away from enemy?

Ok so i use this script here ( to move my player. It is a clicktomove one. Is there a way to edit it so that when he gets at a certain distance away from the enemy, he stops?(and then maybe start attacking). Thanks!

if (unitIsMoving)

  float yourDistance = Vector3.Distance (firstVector, secondVector);
    if (yourDistance <= x)

It checks the distance between two GameObject positions and returns a float. Or really any two Vector3s.

I haven’t looked at that script, but the first line of my pseudocode is basically what would work. Just throw it in an update.