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

I've been seeing this in a lot of scripts. The word 'type'. How do I use this?

I've been wondering how to use 'type' as I've seen people using it so much. For e.g:

if type then
	--Do something
end

1 answer

✓ Accepted answer

Looks like you're having trouble googling that yourself, let me do that for you.

Type Function

In Lua, there is a function called ‘type’ that enables us to know the type of the variable. Some examples are given in the following code.


print(type("What is my type"))   --> string
t = 10

print(type(5.8*t))               --> number
print(type(true))                --> boolean
print(type(print))               --> function
print(type(nil))                 --> nil
print(type(type(ABC)))           --> string

Source

1 comment

0

Thanks alot!

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