Module Scripts: What is the difference between : and .?

Colon syntax is useful for OOP because it passes the table that the function is a member of as self. You can see that if you define and call a function with a colon operator, like below, you will have a variable self.

local t = {}
function t:something()
     print(self == t)
end
t:something()
t.something(t) -- equivalent to the above; colon operator is just syntactic sugar
1 Like