• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

unexpected symbol "else" in expression

erys

Member
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