How can I check if a variable is an Integer?

So, I Have this If statement which checks if a variable is a string or integer… But what do I add after the two '='s?

if type(args) == string then
	ID.Value = players:GetUserIdFromNameAsync(tostring(args))
elseif type(args) == ??? then
	ID.Value = args
end
1 Like
if typeof(args) == "number" then...

This is also worth checking out:

What does type and typeof functions do?

7 Likes

type is quite a bit faster than typeof. I recommend using type unless you are specifically looking for a Roblox datatype value (vector3, cframe, color3 etc)

Also, if you’re looking for an integer specifically and not a float, you’re gonna have to use modulo on it to ensure there is no decimal.

So basically,

if type(arg) == 'number' then
    if arg % 1 == 0 then
        -- do whatever here
    end
end
3 Likes

Yep, I realized that after reading the linked topic in my reply, too lazy to re-edit the reply tho :flushed:

2 Likes