Skip to content

Instantly share code, notes, and snippets.

@gaymeowing
Last active February 7, 2024 16:53
Show Gist options
  • Save gaymeowing/3157f8b02a7de11422368718f5f7fd4f to your computer and use it in GitHub Desktop.
Save gaymeowing/3157f8b02a7de11422368718f5f7fd4f to your computer and use it in GitHub Desktop.
local function AssetTypeToAccesoryType(AssetType: Enum.AssetType): Enum.AccessoryType
local Success, EnumItem = pcall(function(EnumItemName)
return if Enum.AccessoryType[EnumItemName] ~= nil then Enum.AccessoryType[EnumItemName] else nil
end, string.split(AssetType.Name, "Acc")[1])
return if Success then EnumItem else Enum.AccessoryType.Unknown
end
print(AssetTypeToAccesoryType(Enum.AssetType.WaistAccessory)) --> Enum.AccessoryType.Waist
print(AssetTypeToAccesoryType(Enum.AssetType.Hat)) --> Enum.AccessoryType.Hat
print(AssetTypeToAccesoryType(Enum.AssetType.Image)) --> Enum.AccessoryType.Unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment