Hi! I am making a module using OOP and I want to get the type of a value (string, instance, boolean, table, etc.) so I can throw an error if it isn’t the right type of value. Is there an easy way to do this?
1 Like
there is a function for that.
local a = false
print(typeof(a))
print(typeof(a)==“boolean”)
2 Likes
Oh wow, I didn’t know it was that easy. Thanks!
Though it’s worth noting if you want to know if it’s a CFrame or some other Roblox value you need to use typeof(val) instead of type(val). If you don’t know what you’ll need use typeof. (I should have done that in the example tbh)
2 Likes
For primitive types use Lua’s global type()
instead. Never mind, you mentioned that in the other reply.
1 Like