Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Enums
Note
Enums are not a built-in Luau type and they exist only in Roblox, but they're conceptually similar to other Luau data types and are something you'll work with frequently in Roblox development.
The enumeration data type, or Enum, is a fixed list of items. You can access enums through the global object called Enum. For a full list and their respective items, see Enums.
Enum items
To get all items of an enum, call the GetEnumItems() method on it. The following code sample demonstrates how to call GetEnumItems() on the PartType enum.
local partTypes = Enum.PartType:GetEnumItems()
for index, enumItem in partTypes do
print(enumItem)
end
--[[
Enum.PartType.Ball
Enum.PartType.Block
Enum.PartType.Cylinder
Enum.PartType.Wedge
Enum.PartType.CornerWedge
]] Data type
The EnumItem is the data type for items in enums. An EnumItem has three properties:
Name— The name of theEnumItem.Value— The numerical index of theEnumItem.EnumType— The parentEnumof theEnumItem.
Some properties of objects can only be items of certain enums. For example, the Shape property of a Part object is an item of the PartType enum. The following code sample demonstrates how to print the properties of the PartType.Cylinder enum item.
print(Enum.PartType.Cylinder.Name) --> "Cylinder"
print(Enum.PartType.Cylinder.Value) --> 2
print(Enum.PartType.Cylinder.EnumType) --> PartType To assign an EnumItem as the value of a property, use the full Enum declaration. You can also use the item's Name property as a string.
local Workspace = game:GetService("Workspace")
local part = Instance.new("Part") -- Create a new part
part.Shape = Enum.PartType.Cylinder -- By full enum item declaration (best practice)
part.Shape = "Cylinder" -- By enum item's name as a string
part.Parent = Workspace