I’ve created a function using a metamethods to keep track of other tables
Example code:
-- Module
local Module = {}
local functions = {}
functions.__index = functions
Module.new = function()
local Metatable = {
variable = "Hello"
}
setmetatable(Metatable, functions)
return Metatable
end
function functions.Place_Object(self, args)
print(self.variable) -- prints "Goodbye"
print(args) -- Nil
end
return Module
-- Script
local Module = require(module)
Remote_Function.OnServerInvoke = function(player, func)
local args = {
variable = "Goodbye"
}
local NewObject = Module.new()
NewObject[func](args)
end
The self variable is getting replaced with the arguments and I’m trying to know if it’s possible to keep the arguments while keeping self as the Metatable?
- I need the function to print “Hello” instead of “Goodbye”
- I cannot change the function syntax to “:” because I’m calling the function using a variable