What are Enum, Enums and Enumitem?

I’m doing type check for Enum.ListenerType.ObjectCFrame but I don’t really know which one to choose from the 3 options… I’m assuming that I should use EnumItem?

image

sadly I couldn’t find any useful documentation on this

https://developer.roblox.com/en-us/api-reference/datatype/Enum
https://developer.roblox.com/en-us/api-reference/datatype/Enums
https://developer.roblox.com/en-us/api-reference/datatype/EnumItem

2 Likes
  • The object of type “Enums” contains objects of type “Enum”.
  • Each object of type “Enum” contains all the corresponding objects of type "EnumItem"s.

So

  • Enum is (confusingly) of type “Enums”
  • Enum.KeyCode is of type “Enum”
  • Enum.KeyCode.A is of type “EnumItem”

… all of which you can verify by printing typeof(Enum), typeof(Enum.KeyCode) and typeof(Enum.KeyCode.A).

EDIT:

  • If you want to check if a value is of type “EnumItem”, such as Enum.ListenerType.ObjectCFrame, you’d do assert( typeof(enumValue) == "EnumItem" ).
  • If you want to check if a value is a specific type of “Enum”, you’d do assert( typeof(enumValue) == "EnumItem" and enumValue.EnumType == Enum.ListenerType ).
  • If you want to check if a value is a specific “EnumItem”, you’d do assert( enumValue == Enum.ListenerType.ObjectCFrame )
11 Likes