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

is this script right?

2+2=4
if (2 + 2 == 4) then
print("2+2=4. This is correct")
else
print("2+2 is not 4 it is 9. Check your math")
end

1 answer

Yes, except remember that the first line is not valid Lua.

If it's simply a remark about the code (like it is) then it should be in a comment, specified with two hyphens:

-- 2 + 2 = 4

As a stylistic note, the parenthesis around 2 + 2 == 4 are not required and would usually be omitted.

In addition, it is best practice to tab code to make the "blocks" (the things which are part of if, while, for, function, etc) more obvious:

-- 2+2=4
if 2 + 2 == 4 then
	print("2+2=4. This is correct")
else
	print("2+2 is not 4 it is 9. Check your math")
end

2 comments

0

the parentheses around "2+2=4. This is correct" would also be omitted.

0

While they can be, I don't see it very commonly and don't consider it good practice since that can only be done with literal strings and tables.

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