Raycast Destroys player.

Hi,i want my player destroys when he touches raycast,i dont know anything about raycast,so may i ask script example? Please?

Ray rayToCast = Camera.main.ScreenPointToRay(screenPosition);
RaycastHit hit;

//When out is placed in front of a function parameter the variable passed in is also returned, so the RaycastHit "hit" is given data from the Physics.Raycast function, and after the function has finished running you can check "hit" for information related to what the ray collided with.
Physics.Raycast(ray, out hit);

if (hit.collider != null)
{
   //If hit.collider isn't null, that means the ray collided with a GameObject that has a Collider (box collider, sphere collider, mesh collider, etc)
   //You can reference the GameObject the collider is attached to by using "hit.collider.gameObject" 
   //In case you don't know, uppercase 'G' GameObject is the type, while lowercase 'g' gameObject allows you to reference the GameObject a component is attached to. 

   if (hit.collider.gameObject.tag == "Player")
      Destroy(hit.collider.gameObject);
}