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 4 years ago
Edited 4 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:

if challengeLength > enteredLength then
    if challengeString == enteredText then
        print("CORRECT")
    else
        enteredLength = enteredLength - 1
        print("Incorrect")  
else -- This is the else that it causes an error on
    print("Done")
    end 
end

1 answer

Log in to vote
1
Answered by 4 years ago

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

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

Answer this question