Raycasting Not working

I am trying to use raycasting to determine which gameobject is touched using the code that is given in the documentation but its not entering the if loop RAY CAST .Can anyone suggest where i am going wrong:

    if (Input.GetMouseButton(0)) 
    {
		Ray ray;
		RaycastHit raycast;
		ray=Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
		print(Input.mousePosition);
		if(Physics.Raycast(transform.position,-Vector3.up,out raycast))
		{
			print("Ray cast");	
			print(raycast.collider.name);
        }
     }

You are sending the raycast from the transform.position in the direction of -Vector3.up

When you construct a ray, it has both an origin and a direction. Check all the examples in the Unity Scripting Reference :

what I think you’re after is :

if(Physics.Raycast(ray,out raycast))