Storing Enums by their name in a Value object

Hello! I’ve seen a feature request regarding the storage of Enums as Value objects.

While this sadly didn’t become a reality, someone in the thread suggested “storing the enums by their names”. I’m not quite sure how to do that.

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.

In other words, how would I be able to achieve the first option? Storing their IDs isn’t that functional to me. Thanks in advance!

-- store
stringValue.Value = part.Shape.Name

-- load
part.Shape = stringValue.Value
1 Like

ObjectValue instances support objects of the type ‘Instance’.
‘Enum’ is its own datatype independent of the ‘Instance’ class.

And if I were to manually set the value in Studio? Would I just write Enum.KeyCode.F in the String Value?

Your point being…? I was referring to instances (objects) under the “Value” category, so StringValues, NumberValues, IntValues.

It’d just be “F” as that is the name of the Enum.KeyCode.F enumeration item.

1 Like

I was referring to instances (objects) under the “Value” category, so StringValues, NumberValues, IntValues.

Thanks for clarifying, I interpreted your original post as allowing ‘ObjectValue’ instances to support enumeration items.

1 Like