Is there a value abstract class?

Question

We all know the classes that represent values: BoolValue, IntValue, ObjectValue, etc…

I’m trying to create a simple debug menu that keeps track of all values in the game, but every time i need to check if the instance is a class of a value of any kind i need to do this:

if Instance:IsA("BoolValue") or Instance:IsA("IntValue") or Instance:IsA("ObjectValue")  -- (...) then
--Do some debug stuff here
end

This bloats my code a lot and maybe even has performance issues.

I’ve already checked in the dev hub, however i didn’t found anything, so does a value abstract class even exist?

Solution

if Instance:IsA("ValueBase") then
--Do code to manipulate the value (Like showing it in a list?)
end

image

I am not aware of one. But if you use this a lot, you can make it a function.

function isValue(obj)
       if Instance:IsA("BoolValue") or Instance:IsA("IntValue") --[[ect…]] then
              return true
            else
              return false
       end
end

There probably is a more efficient way of doing this but, oh well… :smiley:

1 Like

Yes there is, all the value objects inherit from the ValueBase class.

4 Likes

Oh great, it’s strange that it’s not documented in the dev hub though. (Nevermind it’s right here)

An alternative to the devhub is Anaminus’ Roblox API Reference. I often find it quite helpful to quickly lookup different APIs and classes.

1 Like