What is the correct way to move an object to a target location?

So I have this ship sprite and I’m trying to get it to move to the position of the mouse when I click. The problem I’m having is that Input.mousePosition returns the global position (exact coordinates of the mouse in the scren) like (1280;502) but when I try to make the ship move to that position by doing transform.position = Input.mousePosition the ships goes off screen as it appairs that transform.position uses some sort of relative position.

target = Input.mousePosition;
transform.position = target; //Anything bigger than 10 will make the ship go off screen

Input.mousePosition is in screen coordinates. You want to set transform.position in world coordinates. e.g.

if (Input.GetMouseButtonDown(0)) {

  var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  var hit : RaycastHit;
  if (Physics.Raycast (ray,hit)) {
    transform.position = hit.point;

target = Input.mousePosition;
target.Normalize(); //you can multiply this if the results are too small.
transform.position = target;