Object for Enum Values

As a roblox developer, it is currently impossible to store an Enum value as an actual object to be manipulated.

My case

I’m trying to allow users to remap their own button layouts in my game, and what I had planned to do was something along the lines of this:

that way all localscripts could access the user’s controls settings and directly bind them to UserInputService. Unfortunately ObjectValues cannot store KeyCodes and UserInputTypes so it would be impossible to store input preferences this way.

The Solution

Make an Enum Value object that can store things like KeyCodes and other Enums. I think this would be useful for cases like this instead of having to use a BindableFunction and a Handler to return the bound keycode. I think this would provide an easier way for developers to allow players to remap their controls and improve the quality of games on roblox! Thanks!


You can instead use a StringValue with the name of the enum or an IntValue with its code, which would automatically be converted to an Enum when passed into the Roblox api seamlessly.


The problem with using the value of an enum is that it can change (see this release notes, where the value of several enums for StudioStyleGuideColor were changed). Using the names looks pretty solid, though.