if player = distance, make text visable

The pseudocode pretty much sums up what i’m looking for. I’m not making a game as much as an interactive property plan. I have 3d text with rotators on it, in certain areas. Problem is, i only want them displayed when the “player” is within say 2m of the text. They’re currently displayed 24/7, through terrain dips and objects. It’s interesting, but not what i need. I’m looking for some ideas, in jscript, if you can.

Either you could have triggers that activates them or you could check the actual distance.

//Uses a collider on the text object, requires a rigidbody on the player
function OnTriggerEnter () {
    renderer.enabled = true;
}
function OnTriggerExit () {
    renderer.enabled = false;
}

//Doesn't require any interaction in physics
static var playerT : Transform;
static var showDistance : float = 2.0;
function Start () {
    if (playerT==null) playerT = GameObject.FindObjectWithTag("Player").transform;
    InvokeRepeating("DistanceToPlayer", 0.0, 0.1);
}
function DistanceToPlayer () {
    var sqrLen : float = (playerT.position - transform.position).sqrMagnitude;
    if( sqrLen < showDistance*showDistance) {
        renderer.enabled = true;
    } else {
        renderer.enabled = false;
    }
}