You are searching for your own tag, not the object that was hit tag, change the line “if(gameObject.tag == “Coal”){” to “if(hit.collider.tag == “Coal”){” and that should work
function Update () {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, hit) && hit.collider != null)
{
Debug.Log(hit.transform.tag);
}
}