Which is better? module: or module

I’ve seen some module scripts that use module: or module. to define their functions, is there any difference between the two? Does it matter which should be used?

Example:

module = {}

function module:test()
-- Or
function module.testing()

return module
1 Like

Dots for libraries, colons for objects.

That’s the convention roblox uses for its functions, so I stick to it.

No. The colon syntax is convenience only. Doing someTable:Method("hello") is the same as someTable.Method(someTable, "hello"). In the same way,

function module.test(self)
  print(self) 
end

Is literally the same as

function module:test()
  print(self) 
end

As in, lua adds another parameter automatically. You can define one and call the other, whatever.

3 Likes