# expecting EOF found else. For 2d moving platforms.

I am making a 2d game and I was writing a script for moving platforms. When I finished the code I got a expecting EOF found else. Here is my entire script.’

``````#pragma strict

private var Xpos : float;
private var Ypos : float;
private var max : boolean;

var Vert : boolean;
var maxAmount : int;
var step : float;

function Start () {
Xpos = transform.position.x;
Ypos = transform.position.y;
}

function Update () {
if(Vert){
if(transform.position.y >= Ypos + maxAmount){
max = true;
} else if(transform.position.y <= Ypos)
max = false;
}
} else { // this is the part
if(transform.position.x >= Xpos + maxAmount){
max = true;
} else if(transform.position.x <= Xpos)
max = false;
}
}

if(Vert){
if(!max){
transform.position.y += step;
} else {
transform.position.y -= step;
}
} else {
if(!max){
transform.position.x += step;
} else {
transform.position.x -= step;
}
}
``````

Please don’t post code as an image, post it as code and use the 1010 button; you have an extra squiggly before the ‘else’ that you marked as: // this is the part.

This error means you have unmatched ( ) { }

That’s why i don’t like this bracket-style. You have some closing brackets but no corresponding opening bracket:

line 20 is missing an opening bracket but line 22 has a closing bracket. Same in line 26 – 28

That’s way i use this style:

``````if(transform.position.y >= Ypos + maxAmount)
{
max = true;
}
else if(transform.position.y <= Ypos)
{
max = false;
}
``````

Or if it’s just a single line

``````if(transform.position.y >= Ypos + maxAmount)
max = true;
else if(transform.position.y <= Ypos)
max = false;
``````