• 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!

unexpected symbol "else" in expression

E

erys

Guest
does someone knows why do I get this error ?
Objet : oPlayer Événement : Étape à la ligne 48 : unexpected symbol "else" in expression

GML:
if (!place_meeting(x, y + 1, oMur))
{
            sprite_index = sHuntress_Idle;
            {
            else
            {
                sprite_index = sHuntress_Jump;
            }
        }
}
 

TsukaYuriko

☄️
Forum Staff
Moderator
You're using else, but it doesn't make sense in the context you're using it. else can only follow after an if on the same level.

Pay close attention to your opening and curly braces. Opening another one when you're supposed to close one won't work.
 

Fanatrick

Member
GML:
if (EXPRESSION)
{
    // do things
}
else
{
    // do different things
}
This is the syntax you're supposed to be using as per documentation pages. F1 key opens these documentation pages inside GameMaker Studio.
 

FoxyOfJungle

Kazan Games
GML:
// I think it would be like this:

if (!place_meeting(x, y + 1, oMur))
{
    sprite_index = sHuntress_Jump;
}
else
{
    sprite_index = sHuntress_Idle;
}
 
Top