Help with "attempt to concatenate nil with nil"

I’ve been having a problem, I’m working on a game and I need to abbreviate something so I use my code. But when i try it out it says “attempt to concatenate nil with nil”. I understand this is something to do with the joining of the strings but why if clearly “split” isn’t nil??

elseif n >= 100000 and n <1000000 then
	local stringn = tostring(n)
	local split = string.split(stringn)
	return(split[1]..split[2]..split[3]..","..split[4]..split[5]..split[6])

So, what’s going on here??

you must give a separator parameter to string.split, this is the second parameter.
And since i guess you want every character separated then try giving the string “” as the second parameter

local split = string.split(stringn,"")

2 Likes

Oh I forgot about that second parameter! Thanks.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.