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

How to check if a class set is valid using inverse :IsA()?

Asked by
Nootian 184
3 years ago
Edited 3 years ago

To check if a class is valid, I use this portion of code:

if pcall(function()
    Instance.new(Class):Destroy()
end) then
    print(Class, "is a valid class!")
end

However, when I want to see if the :IsA only classes, such as "ValueBase", creating a new instance with that class will error, and the class will always be invalid. My first thought was to check if :IsA would error, but it just returns false if its not a valid class. How would I achieve this without storing all the :IsA values inside a table somewhere?

Answer this question