Not
There's more than just == to get something that's true or false.
Even then, you could still get rid of the not: not (a < b) is the same thing as a >= b (usually). But do you want to? Is it actually clearer always?
It can be annoying to eliminate these. What's not (a == b or c > d or (e ~= f and not d))? If that's the formula you came up with, is it really clearer to get rid of not?
not also makes for better style.
Usually, you should say if gui.Visible then rather than if gui.Visible == true then because the == true is entirely redundant and makes you have to read more to understand what's going on -- if you don't have == it makes it clear that you either expect true or false and not anything else.
If you want to say it's not visible, you shouldn't say if gui.Visible == false then, you should just say if not gui.Visible then. Doesn't that read nicer?
It's simpler and clearer to sometimes allow you to use not. It also can be used to coerce other values into true and false: not not nil is false and not not 5 is true.
Code after Returns
You can't have code after a return because the return means it's going to leave the function there -- the code after it could never run, since it just stopped.
Lua errors immediately about this because you've probably made a mistake -- you want the print to be before the return so that it can actually happen.
Colors
This is just a weirdness. There are many different notations for Color. One common one uses 0 to 1 for red, green, and blue, and another one uses 0 to 255. They're obviously equivalent, it's just that one is 255 times bigger. The properties tab uses 255, and the implementation of Color3 in Lua uses 1.
in pairs
Most languages let you do many things in several different ways. Lua actually does this much less than most other languages.
pairs(x) is the same thing as next, x, but that is completely opaque. It's much clearer to use a single expression than a tuple.
Because of how for loops work, having next is necessary. However, that's not the best way to write your code -- so pairs is provided, which is what you should use.
1 comment
you just knocked ou me :p