Using ipairs result in the script not finding anything but still thinking the result isn't nil

local result = module.CreateTable("random")
local readTable
readTable = function(got)
	for i, v in ipairs(got) do
		if type(v) == "table" then
			readTable(v)
		else
			print(i..": ", v)
			wait()
		end
	end
end
for i, v in ipairs(result) do
	if type(v) == "table" then
		readTable(v)
	else
		print(i..": ", v)
		wait()
	end
end

This script should print out anything inside of a table, and anything inside of a table that is inside of that table too.
But I used iPairs because the result would come out on the wrong order?
But using just pairs, works fine, but it doesn’t print out anything if I use ipairs!
I need help with this, first of all, isn’t ipairs to make reading tables in order?

-This table is not NIL. I tested it, it’s not.

  • I had the new output when Roblox was down 2 days ago, but now I don’t have it anymore, that’s why i’m trying to print it indivually.

Ipairs reads elements inside a table 1 by 1 but it can’t read Subtables

I just researched a bit, ipairs requires you to do have the same type of value? Is that right?

ipairs won’t iterate over non-numerical indices. What’s in the table?

Here’s a picture: image

Nothing is wrong with that. It outputs fine using your code

image

This means that a piece of your data isn’t actually what you think it is and you should investigate your variables all have numerical indices and are what you expect them to be.

I think this might have to do with how my module works
It converts tables into object-based tables
and can convert them back.

I’m setting the indexes as their name. Which should be a string.
I tried doing tonumber() to check, but it doesn’t seem to work; I’ll investigate and might come back to you if anything is found

You can’t do this and use ipairs. ipairs will not read non-numerical indices.

I know, but it ISN’T non-numerical, the only thing i’m doing here is:
converting that data into a object-based table;
and then converting it back to a table.

I could send you the module and the script if you wanna test it;

It’s up to you if you want to send it. More information would shed light on this problem.

Clearly an index is either non-numerical, nil, or the return is nil and there is nothing to iterate. As much as you are expecting them not to be, the fact that you’re not getting result is proof of this.

1 Like