"On click object disappear" script not working

Heya guys,

So I’ve made a Java script(Unity script) to make an object disappear after you click with your left mousebutton. But I only want it when you are in a certain area. So I’ve made the following script:

#pragma strict

function OnTriggerEnter (other : Collider)

{
    if(other.tag == "Player")

    {

        if(Input.GetMouseButton(0))

        {
    
             GetComponent(MeshRenderer).active = false;

        }

    }
}

The files below will make it more clear.

So I’ve made a collider on the object and attached the script to it.
I really dont know what’s wrong.

I just want to make the axe (bijl) lying on the table disappear

What this would do is make the object disappear if you’re holding down the mouse button when you enter the trigger. If you enter the trigger first and press the mouse button second, it won’t do anything.

There is an onTriggerStay handler as well that runs every frame while in the trigger:

It is perhaps not efficient to re-check the tag every frame, though, so instead you can use the OnTriggerEnter and OnTriggerExit functions to set a bool to true and false, and then in an Update function you can check if the bool is true and the mouse button is down.

Void OnMouseDown()
{
     if(Input.GetKeyDown("Dont Now wich Button"){
        gameobject.destroy();
}
}[/]

Put this in "OnTriggerStay"

Thanks very much both of you guys!!
Worked.

But yet another question … how can I make the axe to come in my hand?
Making a “variable : Transform;”?