Essentially as the title says, what is the difference between : and . in Module Scripts. Here's what I mean:

local MainModule = {}

function MainModule.Test()
end

-- OR

function MainModule:Test()
end

return MainModule

Are they used for different purposes or are they basically the same? All help appreciated! Thanks.

5 comments

0

I believe they are the same. I use : and haven't run into any problems.

0

Thanks, good to know

1

They aren't exactly the same. Calling a function with a colon indicates it's being called as a method, which is an object-oriented programming concept. I'd suggest looking more into that online. I'd write an answer but there's too much to cover and I don't have that much time.

0

Will do. Thanks

0

I get what you mean. Makes a lot more sense now