Stack overflow but the loop is very small?

Hello!
So i’m basically looping trough a table, and if the child is a table itself, loop trough it.
But for some reason, the code gives an error (at the second line) :
Modules.Data:2: stack overflow

Data.GetTableDescendants = function(Table, TableToFill)
	for i, v in pairs(Table) do
		if type(v) == "table" then
			Data.GetTableDescendants(Table, TableToFill)
			return
		else
			table.insert(TableToFill, {i, v})
		end
	end
end

Data.Load = function(Player, SelectedSave)
	local TableDescendants = {}
	Data.GetTableDescendants(SelectedSave, TableDescendants)
end

Does anyone know why?
The “SelectedSave” table is not even that big to cause that…

I believe you want to have the above be:

Data.GetTableDescendants(v, TableToFill)
1 Like

Oh man, i’m so stupid…
I forgot to change Table to v :cry:
Thanks for helping!

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