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

How check if a string is nan (not a number) ?

The title explain everything.

I tried this :

local V = "145"
	if (V) == "number" then
		print("V is a number")
	else
		print("V is not a number")
	end
end)

1 comment

0

I think you meant to use type or typeof ?

2 answers

✓ Accepted answer

You can use type() to get the type of a value.

local V = 145

    if type(V) == "number" then
        print("V is a number")
    else
        print("V is not a number")
    end

3 comments

0

worked thanks !

0

Np :P

0

You guys make no sense. Downvoting something that works? You guys have brain damage.

You can use tonumber() to check if a string can be converted to a number.

local V = "145"
    if tonumber(V) then
        print("V is a number")
    else
        print("V is not a number")
    end
end)

4 comments

0

Thanks

0

That's really stupid.

0

Use type().

0

tonumber is faster and requires less typing

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