What's the difference between table:function() and table.function()?

I’m wondering if there’s any actual difference between the two or is it just aesthetics?

1 Like

So basically it’s just for aesthetic purposes, at least for most use cases

Not really when doing OOP it can make a difference, such as adding less code to your script.
This will help you I suppose

And there are similar posts on the forum regarding this you can check them out.

I’m messing with some OOP rn, and I’m fairly new to Roblox’s OOP. I’ve had experience with OOP with Unity and Java, but I’m just gonna stick to the colons.

In my last post, I forgot to add this one which is very helpful
This topic is based on self but the solution provides an understanding on the " : "

Is there anything similar to Java’s Abstract classes in Lua/Roblox?

As @octanagolamen said (and I should’ve in retrospect), it can be useful for OOP when you want to access the instance rather than the class:

local MyClass = {}
MyClass.__index = MyClass

function MyClass.new(prop)
    return setmetatable({
        property = prop
    }, MyClass)

function MyClass:Print()
    -- self refers to the instance
    -- {property=...}, not MyClass

local a = MyClass.new("A")
local b = MyClass.new("B")

a:Print() --> A
b:Print() --> B

It has been only 5 months I have been doing scripting and I never really did any other language other than lua so I can’t give you an account on that
I have seen some classes in some other languages being created(c++ for example) and I can say oop in lua is quite different.

Alr. I’ve been scripting for a couple of years, and abstract classes are extremely helpful. They’re sort of like template classes you can use for other classes, which would help tremendously with inventories.