Table Error: missing argument #1?

Yea, I was thinking as I did a post asking a question about this:

So I tested that idea, and I come to this error:
missing argument #1

Module Script Code:

local TestTable = {
	TestTable = {}	--this is the Target Table
}


function TestTable.AddLog(TableTest) --This is the function
	local CallBack = pcall(table.insert(TestTable.TestTable,1,'[Test]: '..TableTest)) --Used a pcall to get the error
	if CallBack then --If it works it will respond with a `true`
		print(CallBack)
	elseif not CallBack then --If it does not work it will respond with a error
		error(CallBack)
	end
end

return TestTable

This is the LocalScript that uses the table.insert module:

local TestTable = require(workspace.TestModule)

TestTable.AddLog('Test')

Also, I did another attempt and the same error happened.
So, what should I do, to fix this.

pcall takes in a function

pcall(function() – insert here
end)

You are calling table.insert which returns void/nil. Instead i would utilize pcall’s second argument that allows you to pass additional arguments (a tuple) to the function inputted in first argument:

pcall(table.insert, TestTable.TestTable,1,'[Test]: '..TableTest))
2 Likes