checking the type of a variable

I have a variable that I want to check what type of variable it is (whether its a number, string, table, etc.) Is there any built in function that can do this for me? For example, I want to put in a line like this:

if variable.type() == string then
DO STUFF
end

I might try to make my own function if there isn’t already one there, but a prebuilt function would save me from a lot of work. Thanks in advance

Easy! Lua has a built in function type!

.@edat44 the function is type()

E.g.,

type(“test”) => “string”

type(5) => “number”

Hello @edat44. This chapter of Programming in Lua may help.