Why doesn't this work?

This statement always returns false whether the values actually a string or not. It acts like it isn’t a string, and when i print the type of it then it prints string? I don’t understand what’s going on?

local bucketlist={[1]="joe", [2]="bob"}
for i,v in pairs(bucketList) do
	if type(v) ~= string then
		print(i,v, type(v))
		bucketList[i]="None"
		updated=true
	end
end

it works now

local bucketlist={
	[1] = 2, 
	[2] = "joe"
}

for i,v in pairs(bucketlist) do
	if type(v) ~= "string" then
		print(i, v, type(v))
		bucketlist[i] ="None"
		updated = true
	end
end

just change

if type(v) ~= string then

to

if type(v) ~= "string" then
1 Like