How to turn on text in trigger zone

ive got some hovering text on my NPCs but i want to make them only show when the player is near them, so ive made a sphere collider (isTrigger) in an empty gameobject that is a child of the player and ive written a script turn on/off the GUIText component of the NPC depending on whether it is inside the sphere or outside
but it doesnt seem to be working at all
any help?

#pragma strict

var target : Transform;         // Object that this label should follow
var offset = Vector3.up;        // Units in world space to offset; 1 unit above object by default
var clampToScreen = false;      // If true, label will be visible even if object is off screen
var clampBorderSize = .05;      // How much viewport space to leave at the borders when a label is being clamped
var useMainCamera = true;       // Use the camera tagged MainCamera
var cameraToUse : Camera;       // Only use this if useMainCamera is false
private var cam : Camera;
private var thisTransform : Transform;
private var camTransform : Transform;
var HealthText : GUIText; 
 
 
function Start () {
        thisTransform = transform;
        if (useMainCamera)
                cam = Camera.main;
        else
                cam = cameraToUse;
        camTransform = cam.transform;
        
        
        HealthText = GetComponent(GUIText);
}
 

function OnTriggerEnter (textenter : Collider)
{
	if(textenter.gameObject.tag == "guitextcollider")
	{
		HealthText.enabled = true;
	}
}


function OnTriggerStay (textenter : Collider)
{
	if(textenter.gameObject.tag == "guitextcollider")
	{
		HealthText.enabled = true;
	}
}

function OnTriggerExit (textexit : Collider)
{
	if(textexit.gameObject.tag == "guitextcollider")
	{
		HealthText.enabled = false;
	}
}







function Update () {


        
        
        if (clampToScreen) {
                var relativePosition = camTransform.InverseTransformPoint(target.position);
                relativePosition.z = Mathf.Max(relativePosition.z, 1.0);
                thisTransform.position = cam.WorldToViewportPoint(camTransform.TransformPoint(relativePosition + offset));
                thisTransform.position = Vector3(Mathf.Clamp(thisTransform.position.x, clampBorderSize, 1.0-clampBorderSize),
                                                                                 Mathf.Clamp(thisTransform.position.y, clampBorderSize, 1.0-clampBorderSize),
                                                                                 thisTransform.position.z);
        }
        else {
                thisTransform.position = cam.WorldToViewportPoint(target.position + offset);
        }
}
 
@script RequireComponent(GUIText)

i would say, remove the " gameObject " from the if(textenter.gameObject.tag == “guitextcollider”)
in all the lines that uses that.

then try

if it doesn’t work, i bet i know why it wont. but i just wanna make sure.

i figured out the problem, the gameobject that had the GUIText was moving everywhere while in Game Mode, so even though the Enemy was close, the text gameobject was far (or was close at the wrong time etc) fixed it by putting the script on another part of the enemy and breaking the script in two