Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unsure of why I have an error with an embedded if statement using 'else'?

Asked by 5 years ago
Edited 5 years ago

Within my code I have an embedded if statement which uses the else, however on the first if statement whenever I use else again for the highest if statement it just causes an error and I'm not sure why. Here is my code:

01if challengeLength > enteredLength then
02    if challengeString == enteredText then
03        print("CORRECT")
04    else
05        enteredLength = enteredLength - 1
06        print("Incorrect"
07else -- This is the else that it causes an error on
08    print("Done")
09    end
10end

1 answer

Log in to vote
1
Answered by 5 years ago

You put the end's in the wrong position, here is it fixed:

01if challengeLength > enteredLength then
02    if challengeString == enteredText then
03        print("CORRECT")
04    else
05        enteredLength = enteredLength - 1
06        print("Incorrect"
07    end--Correct placement of the end.
08else
09    print("Done")
10end
0
I did think it was something along the lines of my ends being in the incorrect position, thanks for fixing. RyanTheLion911 195 — 5y
0
No problem! firestarroblox123 440 — 5y
Ad

Answer this question