What's the difference between using : and .?

What’s the difference between using : and . for example:

local somemodule = require(workspace.somemodel)
somemodule.firesomething()
somemodule:firesomethingelse()

So, do they do anything different, if so, what’s the difference?

I haven’t seen a difference, I’m also self-taught so don’t judge me on this lol.
Thanks, Axolix

6 Likes

Using : passes self, the thing that you call the function on as the first argument. So you can restructure part:Destroy() as part.Destroy(part)

5 Likes

: passes table you’re executing from as self.
t.randFunc(self) is the same thing as t:randFunc()

e.g.:

local t = {}
function t.Example1(self)
  print(self)
end
function t:Example2()
  print(self)
end

t.Example1(t) --> t
t:Example1() --> t
t.Example2(t) --> t
t:Example2() --> t
19 Likes

Thanks @Legoracer and @Ankur_007