Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

I did think it was something along the lines of my ends being in the incorrect position, thanks for fixing.

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.