Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Weird empty table appearing in function call?

I have a ModuleScript which looks something like this:

local module = {}

function module:new(player)
	return {
		Method = function(param1, param2)
			-- stuff
			-- When I execute this with the following code there seems to be
			-- 3 parameters the first one being an empty table
		end
	}
end

return module

and a script that requires the mentioned Module, and "instantiates" the module when an event is fired

local helper = require(module_above)

local sections = {
	["SectionA"] = false
}

local helperInstance
local calls = {
	["SomeTagName"] = function(data)
		helper:Method(data.Param1, data.Param2)
	end
}

function event_handler()
	local p = game:GetService("Players"):GetPlayers()[1]
	helperInstance = helper:new(p)

	for name, skip in pairs(sections) do
		local section = script.Sections:FindFirstChild(name)
		if not skip and section then	
			local data = require(section)
			
			for i, event in pairs(data) do
				xpcall(
					function()
						calls[event.Type](event)
					end,
					function(err)
						-- error logging
					end
				)
			end
		end
	end
end

SectionA inside script.Sections being

return {
	{
		Type = "SomeTagName",
		Param1 = "ParamValue1",
		Param2 = {
			"TextLine A",
			"TextLine B"
		}
	}
}

I don't know what's happening here anymore, I hope someone can help me with this ^^"

1 answer

I found the issue...

instead of accessing the function of the helperInstance with '.' I instead used a ':'

This discussion is preserved as it was. New answers, comments, and votes are closed.