Type() vs typeof()?

Why does type() and typeof() return different results? Whats the difference?

20 Likes

typeof is a Roblox function which is meant for getting the datatype of Roblox datatypes as well.

Try executing these two lines:

print(type(Vector3.new()));
print(typeof(Vector3.new()));

The output should be:

userdata
Vector3

Now, I’m curious as to why you made this thread? You got the idea from here: Can we detect what type a variable is?

And a good short explanation was given.

33 Likes

typeof is also Roblox Lua specific, as opposed to type which is available in vanilla Lua.

35 Likes