How to smoothly move object

Hi i currently am trying to use vector3.lerp to smoothly move an object from its open position to its closed but it just jumps and if i lower the smooth it only jumps a small tiny bit what am i doing wrong?

using UnityEngine;
using System.Collections;

public class OpenandClose : MonoBehaviour {
	public Vector3 open;
	public Vector3 close;
	public float smooth;



	public void Open()
	{
		transform.localPosition = Vector3.Lerp (transform.localPosition, open, Time.deltaTime * smooth);
	}

	public void Close()
	{
		transform.localPosition = Vector3.Lerp (transform.localPosition, close, Time.deltaTime * smooth);
	}
}


using UnityEngine;
using System.Collections;

public class openandcloseplayer : MonoBehaviour {

	bool openclose;
	
	void Update() 
	{
		if (Input.GetMouseButtonDown(2))
		{
			RaycastHit hit;
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			if (Physics.Raycast(ray, out hit))
			{
				if (hit.collider.gameObject.tag == "Openable") 
				{
					var script = hit.collider.gameObject.GetComponent<OpenandClose>();
					openclose = !openclose;
					if (openclose == true)
					{
						script.Open();
					}
					else
					{
						script.Close();
					}

				}
			}
		}
	}

}

The reason for this is that because Vector3.Lerp inside your Open and Close functions is getting called just once since it is called from inside if (Input.GetMouseButtonDown(2)) which will be checked for one frame and will call that function in which your object will move by distance depending on smooth value and stop. If you want to move it continuously till it reaches its position then you need to call this Open and Close methods recursively inside Update but outside if (Input.GetMouseButtonDown(2))

Just move your if…else statement for calling Open and Close outside your GetMouseButtonDown check. Then perform a check inside if and else code block if object has reached its target position, if not call Open or Close. Something like:

if (openclose == true)
{
    if(!Mathf.Approximately(script.gameObject.transform.localPosition,script.open))
    script.Open();
}
else
{
    if(!Mathf.Approximately(script.gameObject.transform.localPosition,script.close))
     script.Close();
}

Just put this code snippet out of your if (Input.GetMouseButtonDown(2)) code block

OR

If you want your object to move for the duration of time till the button is held down use if (Input.GetMouseButton(2)) instead of if (Input.GetMouseButtonDown(2))