renderer.enabled false not working

I am trying to write a code so when I press the E key an object go away as kind of the first step for a weapon pick up. I typed the following code but the error “The referenced script on this behaviour is missing.”

function Start () {

}

function Update () {

var tennisPickUp : boolean = false;

if(tennisPickUp) {

renderer.enabled = false;

}

if(Input.GetKeyDown(“e”))

{

tennisPickUp = !tennisPickUp;
}
}

You set tennisPickUp to false every frame and then check to see if it’s false right afterward, which logically it can never be. Presumably you want to define that variable outside Update. Also please format code when posting it in the future.