Bad argument #1 to 'for iterator' (table expected, got nil)

I've been extending the CC Destructable_Manager to add additional information into the spawned object (such as the team that created them)

Im hitting what I assume is a noobie Lua error when I try to pass "componentList" table from the Destructable_Manager script to my own Construction_Manager script

This is the function i added into the Destructable_Manager (it prints what I expect without error)

function PrintAllObjects()
	for component, table in pairs(componentList) do
		print(component, table.team, table.name)
	end
	print(componentList)
	return componentList
end

This is the function in my own Construction_Manager script that tries to get the componentList data from function above...

function Tick()
	Task.Wait(2)
	print("tick")
	destructableMgr = require(propDestructionServer)
	local componenList = destructableMgr.PrintAllObjects()
	print(componenList)	
	for component, table in pairs(componentList) do
		print(component, table.team, table.name)
	end
end

Note, the print(componentList) outputs the same reference in both functions.

However, in the second function the for loop fails with the following error
"bad argument #1 to 'for iterator' (table expected, got nil)"

Which doesn't make any sense to me(!)

it looks like you misspelled componentList ... you left out the t: componenList

Embarrassing...

I spent ages thinking the problem was something more complex and missed the simple typo

Thank you so much

First of all, I don't think you can use the name "table" for a local variable/iterator because it is reserved for dealing calling functions related to tables, for example:

table.insert(myList, 1, A_Value)

Thanks, that appeared to get rid of the error, but the for loop in the second function is still not printing anything.

Its like the return value of the first function is only sending the data structure reference but without the actual data