+2 votes

Hi I just received the following error:

res://Scripts/Game.gd:142 - Parse Error: Expected else after ternary if.

The respective code appears like this:

func saucer_destruction(pos):
    var s = expl_saucer.instance()
    var num = Controller.get_numSaucers() - 1

    if num <= 0 :
        $FlyingSaucer.queue_free()

the "if num <= 0 :" is line 142 and failing with the error message above.

What am I doing wrong, this looks like a standard if statement to me.

TC

in Engine by (20 points)

Make sure the whole script uses the same indentation (tabs or spaces, don't mix them) and that there are no special characters inserted as a result of copy-pasting (such as non-breaking spaces).

You can get this error by forgetting a parenthesis on a variable just above the if statement. It thinks that you are continuing the var line.

thanks @Gingerageous : that was my problem :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.