Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to tell what kind of data is stored in a variable?

local String = "Test String"
local Table = {1,2,3,4,5}

How would I determine which variable stores what kind of data? Does that question make sense, or do I need to clarify?

1 answer

✓ Accepted answer

Use the type() method! So basically,

local String = "Test String"
local Table = {1,2,3,4,5}

print(type(String)) --> "string"
print(type(Table)) -->"table"

It returns a string of the name of your variable's data type. So when comparing:

if type(String) == "string" then -- right

if type(String) == string then --wrong!

1 comment

1

you can also use typeof(), which does the same thing but includes roblox objects. of course, type() is faster if you aren't checking roblox objects :)

This discussion is preserved as it was. New answers, comments, and votes are closed.