• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Got '' expected } or and | Last line error

Object: obj_grid Event: Step at line 20 : got '' expected '}'
I have no idea why I got this error, even when I add } or end it just says the same thing
GML:
if image_index > 87
{
image_speed = 0;
//when skill button not selected
if global.skill_select == 0
{
obj_grid.image_speed = -1.5;
    if image_index == 0
    {
    instance_destroy(self);
    }
//
if image_speed == 0
{
    global.grid_transition = 0;
}
else
{
    global.grid_transition = 1;
}


//Error on this line (because it's the last)
 

Alexx

Member
You have 5 opening {
Only 3 closing }

Formatting your code would make these errors easier to spot.
 

FrostyCat

Redemption Seeker
This topic is a fine example of how inconsistently indented code is worse than unindented code.

Let's indent your code consistently and see if you have the common sense to spot the problem:
GML:
if image_index > 87
{
    image_speed = 0;
    //when skill button not selected
    if global.skill_select == 0
    {
        obj_grid.image_speed = -1.5;
        if image_index == 0
        {
            instance_destroy(self);
        }
        //
        if image_speed == 0
        {
            global.grid_transition = 0;
        }
        else
        {
            global.grid_transition = 1;
        }


        // This is your so-called last line --- did you genuinely think you're done?
 
Brackets were super hard for me to keep track of when I was first learning programming. What I learned works well is to always put your closing bracket before you write any code after the opening bracket. And of course always keep up on your indenting as you are going along.
 
Top