Aim flashlight at cursor in third person

I have a flashlight object which is parented to the left hand bone of a skinned character rig. I want to set up a raycast from the camera to the cursor and detect where it collides with the terrain (the game is a haunted house project, so it is entirely an interior environment) and aim the transform of the hand bone toward that raycast collision, but I can't seem to get it working. Any help?

This script send a ray from the main camera to the mouse position and then rotates the object to the hit point. (Attach it to the object which you want to rotate to the target.)

if (Input.GetButtonDown ("Fire1")) {
  var mousehit : RaycastHit;
  var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  if (Physics.Raycast (ray, mousehit)) {
    transform.LookAt(mousehit.transform);
  }
}

(It is untested with a bone of a skinned character. Maybe you should use the Head Look Controller and modify it?)