How would I shoot out a ray where the mouse is clicked and check for collision in 2D.

Basically what I want is to convert the code below into 2D so that it can detect the 2d colliders tags that the ray hits. I had this working in my 3d project, however simply making everything their 2D counterpart does not work. If someone could help me I would be eternally grateful.

 if (Input.GetMouseButtonDown(0))
    	{
    RaycastHit hit;
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    	if (Physics.Raycast(ray, out hit))
    		{ 
if(hit.collider.tag == "whatever")
    {
    Do something;
    }

For an Orthogonal camera:

Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Collider2D c = Physics2D.OverlapPoint(pos);
if (c != null && c.tag == "whatever") {
    // Do something
}

Note you can also use OnMouseDown() on the object to be clicked.