S-2.1 Simple if Statement
Lets create our first variable and set it to 12
by typing if variableOne then we are essentially telling the compiler "if true then do this" and we follow it up by telling the compiler to execute the code print("value exists") which will print value exists in the output tab. We then finish the statement by typing end (which should have been pre-typed by luau)
This if statement works and prints out "value exists" because as mentioned in S-1, the mere existence of a variable makes it truthy , if variableOne was set to false or nil instead of 12, then nothing would get printed out since the if statement is not satisfied
S-2.2 Equality operator
to set a variable equal to something you use one equal sign however to check equality you use two equal signs next to each other, so this statement is saying if variableOne is equal to 12 then print the following string.
make sure to actually type the second equal sign, as otherwise the compiler thinks you are trying to set variableOne equal to 12 within the if statement, which gives an error
S-2.3 Else if
Here we make use of elseif, when the first statement is false the compiler moves onto the next statement which has a different set of conditions that need fulfilling for the execution of it's code, in this case variableOne must be equal to 14 to satisfy elseif, you can have as many elseif statements as you want, but the first statement has to be if, and only then can you follow it with elseif, it's essentially just basic English
S-2.4 Else
in this block of code, we make use of else , since the first if statement is false the compiler moves onto the else statement and prints that; in Luau using else if like saying "if all statements are false then do this", this becomes more clear when a statement has multiple lines.
Else must come last
S-2.5 putting it all together: if + elseif + else
now we put it all together, remember it must always start with if, it can have 0 to as many elseif statements as you want but it's optional, and it can have 1 else statement which is optional but must come last if included