Move an object to a specific point?

So I’m trying to get an object to move to a specific point on a click. I had this working in a separate scene with just a cube a very simple version of this code;

var smooth: int = 0; 												

private var targetPosition:  Vector3;
 
function Update () 
{
	targetPosition = Vector3 (3.3, -1.49, -4.34);
 
	transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth);
}

This works, however…

// checks for mouse over object
if ( Physics.Raycast ( ray, hit, 30 ))  																									
    {
        // checks if we have clicked the button, and the object has a tag "resource"
      	if ( hit.collider.gameObject.tag == "resource" && Input.GetMouseButtonDown (0))															           	{

            // gets the object _LevelMaster
       		var getResources = GameObject.Find("_LevelMaster");
       		var targetPosition = Vector3 (0, 0, 0);

            // adds 25 to the resourceCount in _LevelMaster
			getResources.GetComponent(LevelMaster).resourceCount += 25;																			
           	getResources.GetComponent(LevelMaster).UpdateHUD ();
           	hit.collider.gameObject.transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * resourceSpeed);												
            //Instantiate ( explosion, hit.collider.gameObject.transform.position, Quaternion.identity );										// plays explosion particle effect	
            //Destroy (hit.collider.gameObject);																									// deletes the object we have hit
       	}
   	}

This does not.

In the second code block, the object snaps instantly to the camera (which is the object housing this script) There is no smooth interpolation over time.deltaTime, and regardless of what coordinates I put in targetPostion, it always snaps to the camera.

Anyone have any ideas?

I see you answered half of the question, related to snapping. As to the second part, I suggest calling a coroutine and executing Vector3.Lerp inside, until it reaches the target. So, instead of this line

hit.collider.gameObject.transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * resourceSpeed);

which probably looks a bit different (after your fix), use this

MoveResource(hit.collider.gameObject.transform, targetPosition, resourceSpeed);

and add a coroutine code:

function MoveResource(resourceTransform:Transform, endPosition:Vector3, speed:float)
{
    var startPosition = resourceTransform.position;
    var t = 0.0;
    while (t < 1.0)
    {
        t += Time.deltaTime * speed;
        resourceTransform.position = Vector3.Lerp(startPosition, endPosition, t);
        yield;
    }
}