Making a Game object appear and dissapear

I am attempting for an RTS Style, and I want this box to disappear, but for some reason it wont do anything.

var isSelected : boolean;
var mesh_on : boolean;
var currentUnit : GameObject;
var speed = 240.0;

isSelected = false;
mesh_on = false;

function Update () {

var Units = 1 << 8;
var Ground = 1 << 9;

var ray = camera.ScreenPointToRay(Input.mousePosition);
var hit_unit: RaycastHit;
	if(Input.GetMouseButton(0)){
	var tempUnit;
		if(Physics.Raycast(ray, hit_unit, Mathf.Infinity, Units)){
		print(hit_unit.transform.name);
			if(hit_unit.collider.gameObject.tag=="Units"){
				currentUnit = hit_unit.collider.gameObject;

tempUnit = currentUnit.MeshRenderer;
isSelected = true;
if(isSelected){
tempUnit.GetComponent(MeshRenderer).enabled
= true;
}else{
tempUnit.GetComponent(MeshRenderer).enabled
= false;
}
}

		}	
		else{
		print("you hit nothing");
		currentUnit = null;
  	isSelected = false;
					if(isSelected){
						tempUnit.GetComponent(MeshRenderer).enabled

= true;
}else{
tempUnit.GetComponent(MeshRenderer).enabled
= false;
}
}

	}
	
	var pos = (Time.deltaTime * speed);
	
	if(Input.GetKey("t")){
	currentUnit.transform.Translate(0, 0, pos);
	}

	if(Input.GetKey("g")){
	currentUnit.transform.Translate(0, 0, -pos);
	}
	
	if(Input.GetKey("h")){
	currentUnit.transform.Translate(pos, 0, 0);
	}
	
	if(Input.GetKey("f")){
	currentUnit.transform.Translate(-pos, 0, 0);
	}
	
var ray_ground = camera.ScreenPointToRay(Input.mousePosition);
var hit_ground: RaycastHit;
}

LoL
Even you try to make thing complex

Use
.active = false;

to Destroy the object Do This:
Destroy(gameObject);

to turn it invisible but it still function normally… Do This:
GetComponent(MeshRenderer).enabled = false;

to turn the object off, but not destroy it (you can turn it back on again later) Do This:
gameObject.active = false;

In your code, every unity has to do a Raycast check to see if it is selected. This is abit of an overkill. I would suggest that you have a different script that manages user input. This would look something like this (in c#)

public class InputManager : Monobehaviour
{
public LayerMask unitsMask;

void Update()
{

    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    RayCastHit hit;
        
    if(Input.GetMouseButtonDown(0) && Physics.Raycast(ray, out hit, Mathf.Infinity,unitsMask ) )
    {
        UnitController unit = hit.transform.GetComponent<UnitController>();
            if(unit!=null) //this check is not really needed as the units will all have the same unique layer
            {
               //I just did a simple selection toggle. you might need a more complex user selection behaviour
                unit. isSelected = !unit.isSelected;
                unit.transform.gameObject.renderer.enabled = unit.isSelected
            }
    }

    }
}

I apologise if I wrote this in C# but I think you get the general idea.