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

What is the difference between 'type' and 'typeof'?

The wiki doesn't really go much into in-depth with the difference, all it says is that 'typeof' is more useful but how?

What is the difference aren't they the same thing?

2 comments

1

typeof extends type meaning if UserData is found Roblox will try ang get its internal type then fall back to UserData.

0

They're the same CallBack methods, ROBLOX is going to deprecate type() soon to replace typeof(), though nothing changed about their functionality.

1 answer

Both type and typeof return what sort of data a variable is referring to. An excellent demonstration is given here: https://www.lua.org/pil/2.html

A frustration one might have in Roblox (before typeof came along) was that you couldn't tell the difference between Vector2, Vector3, Instance, etc - type just said they were all userdata. typeof fixes that problem.

ex:

print(type(workspace)) -- userdata
print(typeof(workspace)) -- Instance

print(type(Vector3.new())) -- userdata
print(typeof(Vector3.new())) -- Vector3

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