linecast detect between two points

Hello! I know this question has been asked already, but I cant seem to solve my problem. I’m trying to
detect a box with the tag “Player”. I’ve seen a few videos and answers but its just not working. Heres the script. This is for a 2D game

	RaycastHit hit;
	if(Physics.Linecast(sightStart.position, sightEnd.position,out hit))
	{
		if(hit.transform.gameObject.tag != "Player")
		{
			print ("Still undetected");
		}
		else
		{
			print ("You Found Me");
		}
	}

Please help me!

I fixed it. Heres the code.

RaycastHit2D hit =  Physics2D.Linecast(sightStart.position, sightEnd.position);

if(hit != null && hit.collider != null){
     Debug.Log ("Detected: " + hit.transform.tag);
}