What's the difference between type and typeof?

I have been messing around with type and typeof which both do the exact same thing which is return variants (or the Class of the Object)

But I was wondering what is their difference, “Apperently” typeof is faster than type, is that true?

Is there more to it?

3 Likes

type is a Lua function and it returns only vanilla Lua data types. Anything else is a userdata type, including Parts, CFrames, Color3s, etc.

typeof is a Roblox function and it handles every Lua and Roblox data type.

10 Likes

Ok so yeah, I’m dumb, anyway

What exactly do you mean by Roblox Data types?

As in Roblox Globals?

3 Likes

Ok, Thanks for Clarifying :slight_smile:

1 Like

Just for you to note, type() is slightly faster than typeof(), so when checking vanilla types such as number, boolean, string, etc. make sure to use the vanilla type function. I also recommend using IsA() for all instances if it needs to be a specific class, as typeof() will only return Instance.

5 Likes

I meant class as in Instance function thread but yeah, I’ll take that.

function and thread are also vanilla Lua types. Take a look here for more on that.

I Do read these, but still, I was referring to that just so you know.
Thanks tho.

Also I rather not keep bumping this.

2 Likes

Another type returned by type() is vector but note the native vector datatype exists only in Luau. But do be aware that vector is only returned when passing a Vector3. Vector2’s, Vector3int16 and Vector2int16 currently don’t return vector, rather userdata (which is another type returned by type())

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.