Vector3 Transform.Position Not Working

In the script below when facing left is true I want my GameObject (the one this script is attached to) to reset its y position and then move it to the right while keeping its new y position. So on play give object a random y position within two specified points and then while keeping that new y position move it to the right. But Vector 3 will not allow me to assign a transform.position to it and gives me the error below.


#pragma strict

var bounceControllerScript : Bounce_Controller_Script;

var objectsOriginalPos : Vector3;

public var smooth : float;
private var newPosition : Vector3;

var stopPositioningTrigger = false;

function Awake ()
	gameObject.transform.position.x = -8;
    objectsOriginalPos = transform.position;

function Update ()

function PositionChanging ()
	if (Bounce_Controller_Script.facingLeft == true)
	    var newPosition : Vector3 = new Vector3(-2.68, objectsOriginalPos, 0);
	    transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime);


BCE0024: The type ‘UnityEngine.Vector3’ does not have a visible constructor that matches the argument list ‘(float, UnityEngine.Vector3, int)’.

You are not passing the right values to the new vector3.

Try changing this:

var newPosition : Vector3 = new Vector3(-2.68, objectsOriginalPos, 0);

To this:

var newPosition : Vector3 = new Vector3(-2.68, objectsOriginalPos.y, 0.0);

you are using the whole objectsOriginalPos : Vector3 as the Y component in the new call. You should access the Y component of the position:

new Vector3(-2.68, objectsOriginalPos.y, 0)