Question about ModuleScripts

When you type:

function module:method()
end

What you’re actually saying is:

function module.method(self)
end

Similarly, a:b() translates to a.b(a). This is a feature for Lua object oriented code, which you should omit when you’re not making use of it. self is the built in name for the automatic parameter : inserts into the function.

Here’s a post that goes more into detail on this, but I just suggest avoiding it altogether until you find yourself in a situation that calls for it, since it isn’t directly related to this OP. All about Object Oriented Programming

1 Like