How to make dialog systems?

Heres my script →

#pragma strict
var Bob : Transform;

function Update () 
{
  if(Bob) {
    var distance = Vector3.Distance(Bob.position, transform.position);
    GUI.Button(Rect(10,10,10,10),"Hello Player");
    
   }
}

Im making it if the distance like 0.5 near the player it shows the dialog.
How can i fix this?

To fix the distance issue you need to make it into a condition as well,

  if(Bob) {
    var distance = Vector3.Distance(Bob.position, transform.position);
    if (distance>.5) 
        GUI.Button(Rect(10,10,100,16),"Hello Player");
   }

Keep in mind you should have your GUI elements within OnGUI(). Another thing is that your original rect size is too small to fit the text “Hello Player”, a rect is defined with offset from left, offset from top, width and height. Increase the third, and probably the forth, value a bit.