Need javascript for moving a 2D object left and right

Hi. I need a javascript for moving a 2D object left and right. Could you plz put it up. Thnx

var speed : float = 6.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {

var controller : CharacterController = GetComponent(CharacterController);

	if (controller.isGrounded) {

	
	moveDirection = Vector3(0, 0,-speed);
	moveDirection = transform.TransformDirection(moveDirection);
	moveDirection *= speed;

	}

	controller.Move(moveDirection * Time.deltaTime);

}

That should work u may need to change speed in the Vector 3 Depending on your direction