Thanks to everyone who helped im very grateful. The Script Works and destroys the object fine.
This is my Code
EDIT : Changed it but still does not work
UPDATED SCRIPT Thanks To alucardj
PS
! I can hit the object and it shows in the debug but it still doesn’t destroy it !
if (Input.GetMouseButtonDown(0)){
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit, 1000)){ // 1000 or Mathf.Infinity should be enough !
// what did the raycast hit ?
Debug.Log( "ray hit (name): " + hit.collider.gameObject.name);
Debug.Log( "ray hit (tag): " + hit.collider.gameObject.tag );
if(hit.collider.gameObject.tag == "prop")
{
Destroy(hit.collider.gameObject);
}
}
}