How to prevent an object from teleporting to another object on mouse-click?

I have a character in my scene and when I click on an object, I want the character to move to that object. That part works great except that when I click, my character teleports to the object. How would I write the script so that my character moves slowly toward the object (like he is walking to it). Here is what I have so far…
(JS)

var window : GameObject;
var boy : GameObject;

function OnMouseDown(){
boy.transform.position = window.transform.position;
 }

 function Update(){
 transform.position = Vector3.Lerp(boy.position, window.position, Time.deltaTime);

Here is a script. It uses MoveTowards() instead of Lerp(). Lerp would take a little more doing. Note the way you have this structured, whatever object you have this script attached to is the one that get the click, and it does not have to be either the window or the boy.

var window : GameObject;
var boy : GameObject;

var targetPosition : Vector3;
var maxDistancePerFrame = 0.1;

function Start() {
targetPosition = boy.transform.position;
}

function OnMouseDown(){
	targetPosition = window.transform.position; 
 }
 
 function Update(){
 	boy.transform.position = Vector3.MoveTowards(boy.transform.position, targetPosition, maxDistancePerFrame);
 }

Try something like this instead. I’m not posotive on the actual calls, you may need to look them up in the script reference, but I’m pretty sure I’m pretty close.

var move : bool = false;

function OnMouseDown()
{
   move = true;
}

function Update()
    {
      if(move)
      {
       transform.position = Vector3.Lerp(boy.position, window.position, Time.deltaTime);
      }
    }

Why your code isn’t working, is you’re saying, "When I click, set my character position to the windows position, and then in update your lerping to it. So it’s slowly moving there over time, but then you click and it teleports there. You want to slowly move there when you click, so you want to only lerp when you click. Hopefully this will at least help.