Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i get the enum value of an enum?

Asked by 4 years ago

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
0
I'm pretty sure you can't do that. User#32819 0 — 4y
0
I'm pretty sure you can't get an Enum value into a Variable. Dovydas1118 1495 — 4y
0
you can do it, see accepted answer. VerdommeMan 1479 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

Ad

Answer this question