Cannot destroy GameObject using the Destroy() function?

I’ve been at this for hours now, and I’ve tried various things but none of them worked. Here is my script right now:

var primitive : GameObject;
var clone : GameObject;

//Here is what I'm using now(Still a no-go for some reason):
function Update ()
{
//Spawn, then destroy primitive if M1 is clicked:
if(Input.GetMouseButtonDown(0))
   {
clone = Instantiate(primitive, transform.position, Quaternion.identity) as GameObject;
 Destroy(clone);
   }
}

I was just testing to see if a GameObject would destroy properly like in the docs, but it just isn’t working. I used every variation of the Destroy function, tried the solutions I found on here, and still, absolutely nothing works. I’m afraid I’m just overlooking something, but as far as I can tell, all of my variables are in the scope they need to be in, I’m using a GameObject for the primitive variable, and I’m assuming the clone variable is assuming correctly.

I tried to statically declare clone as a GameObject, but that didn’t work, either.

Thank you for reading this!

I’m not sure this is right as it depends on how you attach the script to what object and i guess you’re assigning a primitive. However, if it is that, I suspect that you are in fact destroying the clone, but the clone is placed directly over the original primitive so it appears it’s still there. Just a thought.

As syclamoth says it is an unusual test case, which may not be helping.

Actually your code works quite well, but you are creating and destroying the primitive in the same event, left mouse click and you are not able to see it on screen because it happens in a 1/60 of a second or less. Try this, is C# code:

public class TestDestroy : MonoBehaviour
{
    public GameObject primitive;
    private GameObject clone;

    void Start()
    {
        clone = (GameObject)Instantiate(primitive, transform.position, Quaternion.identity);
    }

    void Update ()
    {       
        //Spawn, then destroy primitive if Left Mouse Button is clicked:
        if(Input.GetMouseButtonDown(0))
        {
            Destroy(clone);
        }
    }
}