Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i get the enum value of an enum?

Example:

Enum.KeyCode.One has as enum value: 49

How do i get this value when i have the enum?

This way i can write the following code which is a lot shorter than the alternative

local function manageInventory(input, gameProcessed)
	local key = input.KeyCode - 48
	if 0 < key and key < 7  then
		if inventory["ViewportFrame"..key].BorderColor3 == unactiveColor then
			unselectAll()
			inventory["ViewportFrame"..key].BorderColor3 = activeColor
		else
			inventory["ViewportFrame"..key].BorderColor3 = unactiveColor
		end
	end
end

3 comments

0

I'm pretty sure you can't do that.

0

I'm pretty sure you can't get an Enum value into a Variable.

0

you can do it, see accepted answer.

1 answer

✓ Accepted answer

For any enum with a value, you just have to index the Value from the enum, in your specific case it would be like this

Enum.KeyCode.One.Value

This discussion is preserved as it was. New answers, comments, and votes are closed.