Dialog system bugs?

Heres my new script and when my player collects 70 energy and i get back to the cube the GUI doesnt shows.
var Bob : Transform;
var Player : Transform;
var cameraMove : Camera;

private var distance : float;
 
function Update ()
{
    if(Bob)
        distance = Vector3.Distance(Bob.position, transform.position);
}
 
function OnGUI ()
{
    if (distance <= 5)
    GUI.Button(Rect(200,180,510,120),"Hello Player! Will you pls collect 70 energy for me?");
    QuestAccepted();
    print("Player is near BOB");
    
}

function QuestAccepted()
{
  if(PlayersEnergy.PlayerEnergy == 70)
  {
     if(distance <= 5)
     GUI.Button(Rect(200,180,510,120),"Thank you!");
  }
}

function OnGUI() {

		if (distance <= 5) {
			
			print("Player is near BOB");
			
			if(PlayersEnergy.PlayerEnergy >= 70)
				GUI.Button(Rect(200,180,510,120),"Thank you!");
			else
				GUI.Button(Rect(200,180,510,120),"Hello Player! Will you pls collect 70 energy for me?");
		}
}