ScreenPointToRay return question

Hello,
New to Unity, not to programming though. I’ve been working on a simple game and I’m having problems with getting the mouse position using ScreenPointToRay. Basically I have a sidescroller, and I have a cube that I want to move to wherever you user clicks.
The code I’m using is below.

public var thiscamera: Camera;

if (Input.GetMouseButton(0))
{
var ray: Ray = thiscamera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;

if (Physics.Raycast(ray, hit))
{
if (hit.transform == target1)
{
print(“Hit target 1”);
Debug.Log(hit.transform.position);
Debug.Log(“Screen” + thiscamera.main.ScreenPointToRay(Input.mousePosition));
}
}
}

The problem I’m having is that, shouldn’t the Logs spit out the same number? Since I’m printing the position of the cube, and the position of the mouse when I click on the cube? It basically just gives me the camera position again?
Any help would be greatly appreciated.
Thanks

in the second log you print out the ray and not the point where it hit the object. use hit.point instead. they won’t print the exact same numbers though, the second one will print the point where the ray hits the collider and the first one prints the coordinates of pivot of the object it hit

Thanks! Got it now, thanks for your help.