Scripting a GUI button to move object smoothly

Im having trouble with the Js ive written below.

Im creating a GUI button that when clicked moves the player to a defined position using the SmoothDamp function.
But cant seem to get the code working and help or tips would be excellent.

var target : Transform;
var smoothTime = 0.3;
private var velocity =;

function OnGUI () {
if (GUI.Button (Rect (150,10,140,70), “Fly me to earth”)) {

OnMouseDown () {	

var targetPosition : Vector3 = target.TransformPoint(Vector3(0, 5, -30));

transform.position = Vector3.SmoothDamp(transform.position, targetPosition, velocity, smoothTime);



Thanks in advance J

Try creating a MoveTo(destination) method that moves the player in increments towards the destination and keeps moving until it reaches it. You can then re-use the method to move the player wherever you want and at whatever speed you want.