Forest Logo
search
package_2

typedenum

By @arythmitical

Roblox

Mirrored

TypedEnum

Construct custom enums at runtime, with proper autocompletion and typechecking.


local PlayerLocation = TypedEnum.new(function(add)
    return {
        MainMenu = add("MainMenu", 1),
        InRound = add("InRound", 2),
        Shop = add("Shop", 3),
    }
end)

export type PlayerLocation = TypedEnum.TypedEnumItem<number, typeof(PlayerLocation)>

local location: PlayerLocation = PlayerLocation.MainMenu

OnLocationChanged.OnClientEvent:Connect(function(id)
    local newLocation: PlayerLocation? = TypedEnum.fromValue(PlayerLocation, id)

    if newLocation then
        location = newLocation
    end
end)

Package Details

Install command (Click to copy)


Version

1.0.4

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.