Table pack weird bug

I’m so confused on how this works on the first function, but not function two? The order gets messed up and nil?

function Knight:AddItem(ItemGUID: string, ItemSlotData: KNIGHT_TYPES.ItemSlotData): boolean
	print("Second func:", ItemGUID, ItemSlotData)

			if Action == "CallFunc" then
				local funcName: string = args[1]
				local funcArgs: table|nil = args[2] or {}
			
				warn("Unpacked: ", table.unpack(funcArgs))

				local func = self[funcName];

				local function foo(a: string, b: KNIGHT_TYPES.ItemSlotData)
					print("First function;", a,b)
				end
				
				foo(table.unpack(funcArgs))

				return func(table.unpack(funcArgs))
			end

What do the contents of the {…} look like for the first function output, and the second function output? Does the second function output still contain the GUID, just doesn’t unpack it?
If you give it harded coded values, e.g. ‘a’, ‘b’, instead of the unpacked table, what does the second func output?

Content’s of {} is just a table of data. Weirdly passing “nil” in front of func somehow fixes it? Idk it’s werd.

For clarification, Knight:AddItem is a metatable.

After further research, apparently first parameter is suppose to be something for self of a metatable.

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