So, some people have told me that some object properties use a string value, some use Enum, and some can use both. But they can't stress it enough that if they have the option of Enum, that i use it over a string. Is this true? They both work the same, so i can't see the difference.
For example:
-- Assuming this is in a text label script.Parent.Font = Enum.Font.ArialBold -- Instead of ... script.Parent.Font = 'ArialBold'
So, it's a little blurry to me since both of these methods work the same, but using a string is just generally shorter. Any good reasons?
When setting you can use either string, Enum, or number.
Number is bad, because it's not human readable. Always prefer string/enum to number.
String is human readable, but you could have made a typo.
Enum is human readable, and should prevent typos. However, it's longer.
However, when you get a value, you "have" to use Enum.
if part.TopSurface == "Smooth" then
That will not work. That's because ==
first checks that the two things are the same kind of thing. But "Smooth"
is a string and TopSurface
will be an Enum, so that comparison will always be false
.
In that case, you have to use Enums.
The choice is up to you! The two options are the same.
I personally use strings, since I know them perfectly.
One advantage of using 'Enum' is that, if you're typing in Roblox Studio's script editor (or command bar), its intellisense will automatically show you valid properties of "Enum" and then of "Enum.Font"