Get Updating Vector3 position of player?

Hello,

I am fairly new to coding so please excuse lack of knowledge on this matter.

To start, I am essentially attempting to create a self-updating coordinates system of sorts. I need to determine how for from a game object a player is to decide whether or not they are able to interact with it. So far I have this:

public GameObject button2;
public GameObject door;
public GameObject Fire1;
public GameObject Fire2;
public GameObject Fire3;
public GameObject TireMaker;
public GameObject player;

public float distance;
public float playerDistance = 5;

public void Start(){
distance = Vector3.Distance (player.transform.position, button2.transform.position);
}

public void OnMouseDown(){

	if(playerDistance > distance){

		gameObject.SetActive(false);
		button2.SetActive (true);
	button2.GetComponent<AudioSource>().Play ();

	Fire1.SetActive (true);
	Fire2.SetActive (true);
	Fire3.SetActive (true);

	TireMaker.GetComponent<AudioSource>().Play();

	door.transform.Translate(2, 0, 0);
	door.GetComponent<AudioSource>().Play ();
	}
}

This is able to determine how far the player is from the gameobject at the start of the game, however, I need a sort of loop to continuously determine whether the player is within the playerDistance. Once in the distance criteria, the object can then be interacted with. Therefore, I just need help creating a loop I believe. Also, if it is possible to kill the process of the loop after the object has been used, that may be helpful as the object is only used once and thereafter the coordinates are not needed.

Thank you for any input you may have!

Fixed it myself. I overlooked the fact that I was determining the distance prior to the click and therefore, it was only registering the distance as I started the game. Instead I just moved around some code like so:

public void OnMouseDown(){
distance = Vector3.Distance (player.transform.position, button2.transform.position);
if(playerDistance > distance){

Placing the distance variable under the OnMouseDown void made it so when the player attempted to click the button the distance would be checked and then the if statement would determine whether the button was close enough, etc.