Detect Enemy Player Script

Hi,

So I am trying to detect a enemy when the player clicks them. THis is a 2D project, and I, for the life of me, can’t figure out why my IF condition that I am comparing the tag is always false?

if (Input.GetMouseButtonDown(0))
        {
            RaycastHit mouseHit;
            Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(mouseRay, out mouseHit))
            {
                if (mouseHit.collider.CompareTag("Enemy"))
                {
                    Debug.Log("This is a Enemy");
                    hpCanvas.gameObject.SetActive(true);
                }
                else
                {
                    Debug.Log("This isn't a Enemy");
                    hpCanvas.gameObject.SetActive(false);
                }
            }

        }

Your help is much appreciated!

Thanks,
Andy

Right before that if statement on line 7 put Debug.Log(mouseHit.collider) and see what that gives you, also you can do a == comparison with a collider