EnumTable | Way to create Enums (Technically)

Hello, today I am with you with my new script called “EnumTable”, which allows you to create Enums (technically). You can get it here.

What do you mean technically?

What I mean is, you don’t actually create an EnumItem. You just store some data into the module script, so you can use it with any script anywhere.

Why would I use that?

If you are interested with Enum, it would actually be useful for you if you want to create your custom Enum values.

Functions Included

Module:CreateCategory()
Module:RemoveCategory()
Module:CreateEnum()
Module:RemoveEnum()
Module:EditEnum()

How to get the Enums that I've created?
local Module = require(EnumTable)
Module:CreateCategory("AnyCategory")
Module:CreateEnum("AnyCategory","WorkspacePath",workspace) -- The first arg is the category name, the second one is Enum name, and the third one is Enum value.
print(Module.AnyCategory.WorkspacePath.Name) -- Expected: Workspace

Please let me know your ideas, in the comments.

1 Like

I’ve seen more modules that do this, but this is the first time I see this type of Enum to be edited. A question though, does it have functionality as the real Enum (Value, Name, EnumType not needed)?
image


Something I would like to see is the ability to add “Enum” items In-Studio, not only using functions.


You seem to be added 2 Module:EditEnum() in your Functions Included part.

1 Like

Hello, thank you for your comment. It actuallly needs all of the args mentioned in the function. Also thank you for letting me know that I have added 2 of the same functions.

Oh also, about the last part. I can make it a plugin, but you currently gotta set up it for each server. With a plugin, I can make it data storage so it will be global.

Have a good day!

1 Like

Cool module, but this can be accomplished by doing something like this:

local EnumTest = {
  local EnumCategory = {
    MyEnum = "MyEnum";
    Better = "Better";
  }
}

game:GetService("ReplicatedStorage").PlayerInput.OnServerEvent:Connect(function(plr: Player, inpt: string)
  if inpt ==EnumTest.EnumCategory.MyEnum then
    print("Player selected MyEnum.")
  else
    print("Player selected Better.")
  end
end)
1 Like

Yes, but you can’t always edit the Enums anytime normally. This is what makes the script special.

local EnumTest = {
  local EnumCategory = {
    MyEnum = "MyEnum";
    Better = "Better";
  }
}

game:GetService("ReplicatedStorage").ModifyEnum.Event:Connect(function(name: string, category: string, newval)
 EnumTest[category][name] = newval;
end)

You can already do this by just modifying a tables values, with a single line

2 Likes

Yep, but this way is less complicated for beginners. And it is my purpose to make it easier for them.