How to connect RayCast and GUI Text?

var hit : RaycastHit;

function Update() {
if (Physics.Raycast (transform.position, transform.forward, hit, 10) && hit.collider.gameObject.CompareTag("Player")){
print ("detected!");
guiText.text = "Pick Up";
}
else {
print ("nothing..");
}
}

How can I make my guiText become a string (“Pick Up” in my case) when its detected by the RayCast?

Simple, you just have to have a variable for weather or not the text should display

var ShowText:boolean = false;

//First lets check for the raycasting
function Update() {
    if (/*Physics.Raycast stuff here*/) {
        ShowText = true;
    }
    else {
        ShowText = false;
    }
}

//Now let's display the GUI
function OnGUI() {
    if (ShowText) {
        GUILayout.Label("This is some Text"); //This is a GUI function that displays text automatically on the screen
    }
}

Hope this clears things up,
Benproductions1