Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Enumeration problems that i do not get?

Asked by 7 years ago

Ok, so, I know that enum holds a value but I am still unsure to when it can actually be used and what it is used for. I see it used for so many things that I am confused as to what I can use it for. Any tips?

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
7 years ago

Enumeration is basically a table of tables that Roblox uses to identify different aspects of object properties. It starts off with the initial indexing of the table which to us is "Enum". Much like how you would go "game." when you want to access the DataModel and its elements.

Enum is basically that hard coded variable that would then direct you to subcategories. Some of these subcategories being ButtonStyles for Guis, KeyCodes for UserInputService, or CameraType for Camera Manipulation. You can review the whole list of Enumerations here.

You would then use those subcategories to find what value you want to set the property you're trying to set. When you find the name of the value in the Enumeration you want to set the script will get the value when it goes to run. This is typically for properties we can not necessarily set on our own and must be rendered by the game engine.

Enum = {
    Type = {
        Block = "SomeValueTheScriptTranslatesHere";
        Sphere = "SomeValueForSphereTheScriptTranslates";
    }
}

As you can tell the actual coding of Enumerations are more complex than this. Roblox has even allowed users to use numbers and strings in order to access these values than to use Enumerations. So that is why you might see Object.Shape = "Ball" or maybe other code like that. Roblox will back track, "oh they gave me a string named Ball, let me see they're looking for a shape, found the enum". Once again, more complicated than that.

Basically what Enumerations are used for is setting values we can't really set manually. Other people in depth to game making might be able to provide a better answer (most likely BlueTaslem). If you have any questions, feel free to leave them in the comments below. If this answered your question, then do not forget to hit the accept answer button. Hopefully this helped you gain some understanding as to what Enums do.

0
An Enum is actually (Especially in Roblox) a set of values which relate to a name, a number and an object. User#6546 35 — 7y
Ad

Answer this question