String expected got nil

i’m trying to load xp info for specific items and i know it loads but i am confused why i keep getting the error “invalid argument #1 to ‘split’ (string expected, got nil)”

if data ~= nil then
	print(data)
	for i, v in pairs(DataStuff:GetChildren()) do
		print(v)
		local Need = tostring(v)
		local splitString = string.split(data[Need], "@")
		print(splitString)
		local Exp =  splitString[2]
		print(Exp)
		local XpR
		local Lvl
	end
else
	for i, v in pairs(DataStuff:GetChildren()) do
		v.Value = 0
	end
end	

end

The error means data[Need] returns nil instead of a string to split

1 Like

yeah i’m trying to figure out why because i’ve used some print statements to check that it’s a string and it is when i get it

Can you show us the print statements?

nvm i figured it out… and now to meet the character requirement

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