Destroy the object i am looking UNITY 3D

Hello, I am making a building game and I want to click and destroy some blocks I have placed before.
I made a script in the blocks(they are clones)

if (Input.mousePosition == gameObject.transform.position)
        {
            if (Input.GetMouseButtonDown(1))
            {
                Destroy(gameObject);
            }
        }

Any solution how can I make this work? Maybe with raycast but I tried something and didn’t work.
Thanks

function Update ()
{
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay ( Input.mousePosition );
hit = Physics.Raycast (ray, 30);
if (hit && Input.GetMouseButtonDown(0))
{
Destroy(hit.collider.gameObject.name);
}
}