You can try using this function that i made, Then all you need to do is to write the first parameter (EnumList) as a string. EnumList is Enums like Font, FontSize, HumanoidRigType, etc. EnumChild is the Child which you want to check if it exists.
local function DoesEnumExists(EnumList: string, EnumChild: string): boolean
return pcall(function()
return Enum[EnumList][EnumChild] ~= nil
end)
end
if DoesEnumExists("Font", "Arial") then
print("Arial Font Exists!")
end
I’d avoid using pcall() when there are other alternatives as it’s not very performant. Here’s a function which takes two parameters, the first of which represents an enum list & the second of which represents an enum item.
local function doesEnumExist(enumList : string, enumItem : string) : boolean
for _, _enumList in ipairs(Enum:GetEnums()) do
if tostring(_enumList) == enumList then
for _, _enumItem in ipairs(_enumList:GetEnumItems()) do
if _enumItem.Name == enumItem then
return true
end
end
end
end
return false
end
print(doesEnumExist("PartType", "Block")) --true
print(doesEnumExist(math.huge, math.pi)) --false