Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do i get the enum value of an enum?

Asked by 2 months 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. zamd157 613 — 2mo
0
I'm pretty sure you can't get an Enum value into a Variable. Dovydas1118 993 — 2mo
0
you can do it, see accepted answer. VerdommeMan 1162 — 2mo

1 answer

Log in to vote
0
Answered by 2 months ago
Edited 2 months 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