Hand-written by Joseph San Nicolas, Roblox Developer
Enum
Constructors
| Name | Description |
| Enum.<EnumName> (e.g. Enum.KeyCode, Enum.Material) | Enum has no direct new() constructor. Every Enum is a built-in global accessed by name off the Enums singleton (the global Enum table), for example Enum.KeyCode or Enum.Material. |
Code Snippet
local Material = Enum.Material
for _, item in Material:GetEnumItems() do
print(item.Name, item.Value)
end
local wood = Material:FromName("Wood")
print(wood == Enum.Material.Wood) --> true
Methods
| Name | Parameters | Returns | Description |
| GetEnumItems() | Void | {EnumItem} | Returns an array of all EnumItem options available for this Enum. |
| FromName(name: string) | name: string | EnumItem? | Returns the EnumItem in this Enum whose Name matches the given string, or nil if no match exists. |
| FromValue(value: number) | value: number | EnumItem? | Returns the EnumItem in this Enum whose integer Value matches the given number, or nil if no match exists. |