Look at an object in 3d space

So I have the player, a ship, in 3d space, and I want to look at a point in space. I am finding the point by casting a raycast from the camera to mouse on to a plane, and then geting that point, and looking at it. However, my script is not working. Any ideas?

var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Debug.DrawRay (ray.origin, ray.direction * 40, Color.yellow);
var hit : RaycastHit;
var hitPoint = hit.point;
transform.LookAt(hitPoint);

between var hit: RaycastHit; and var hitPoint = hit.point, you haven’t cast the ray to actually hit anything. You need to do that. Look at Raycast