Help please with code, moving and collision *Fixed*

Why isnt this java script working, please help me

#pragma strict

private var IsMoving = false;
var Moving = 3;

function Start ()
{
	IsMoving = false;
}

function Update ()
{
	if (IsMoving == false)
	{
		if (Input.GetKeyDown(KeyCode.D))
		{
			IsMoving = true;
			while (IsMoving == true)
			{
				if (Vector3.x == "Cube") <--- this isnt working, some info: collision, collision name =  cube.
				{
					Moving = -1;
					IsMoving = false;
				}
				else
				{
					transform.position.x = transform.position.x +1;
				}
			}
		}
	}
}

Try adding a CharacterController the object you are controlling, collisions should work.

#pragma strict

function Start () {

}

function Update () {
    var movement : Vector3 = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
    GetComponent(CharacterController).Move(movement);
}

Check out the Unity Tutorials, many basic things are covered there.

if is fixed close this or remove this post