Im trying to make the module function use : instead of this .
Example, of what I’m trying to do.
local TestModule = {}
local value = game.ReplicatedStorage.Test
TestModule[value.Name] = function(Message)
print(Message)
end
TestModule.Test("-_-")
if I trying using TestModule:Test() It would print TestModule Instead of the argument
1 Like
Object:func is only for OOP. Programming in Lua : 16
1 Like
M9_Sigma
(Final_Sigma)
3
When calling a method with a : it first references the module in the first argument (commonly referred to as self).
i.e.
local Module = {}
Module.TestVariable = false
function Module.foo(self, Message)
print(self.TestVariable)
print(Message)
end
Module.foo("Test")
return Module
You can also define a function with a : to have self be included by default
function Module:foo()
print(self)
end
1 Like