Tonumber returns nil when there is a number

  1. What do I want to achieve?
    Roblox to realise 1 is a number. - BanLength is args[2] which is a string with a value of “1”. Tonumbering BanLength returns 1 like normal.

  2. What is the issue?
    Roblox says 1 is not a number. - BanLength is args[2] which is a string with a value of “1”. Tonumbering BanLength returns nil.
    image

  3. What solutions have I tried so far?
    Asking other people, printing the outcome of tonumber(banlength).

1 Like

Try Changing the banlength variable to tonumber(args[2])

From what I see, the only way that it returns nil is if banlength is nil, which happens in your case if it doesn’t match the checknamenow ~= false nor the getId criterias, There doesn’t seem to be much of a point ot put that in its own variable, use args[2] as normal as @shadowmaster940 said

1 Like

image
This only displays if one of the criterias were met, as if a criteria is met noterror is changed to true. By default it is false.

Seems like you’re changing noterror to true even if there is a valid name

After printing the original non-tonumber value, it also returns nil. I am attempting to fix the issue right now however I also print the args table, and args[2] exists.
image

I feel like it’s related to the table.remove you’re doing at the start of the code you sent, you may be doing them on reason, but tables work by reference, so it removes it from args as well

This was the solution! I knew this could be something however I thought the tables would duplicate. Mistake on my part but thank you for helping me solve this problem!

1 Like

If you want to clone a table, you have to make a new table and add the contents of the first table to the new table, though from what I see you don’t really need to do cloning if you just want the reason, instead just start looping from 3 to the end of the table to get the reason string