I know someone above suggested using inheritance, but maybe this approach would be better suited for what you’re trying to accomplish? If it’s not, you should elaborate on why the previous suggestions were not suitable for this task.
-- first module script
local parent = {}
function parent:new()
local obj = {}
setmetatable(obj, self)
self.__index = self
return obj
end
function parent:test()
print("testing")
end
return parent
-- second module script
local child = require(pathToParent):new()
function child:new()
local obj = {}
setmetatable(obj, self)
self.__index = self
return obj
end
function child:test2()
print("another test function")
end
return child