Weird, I was a following a tutorial and that’s what the tutorial said? Can you watch through it?
So what IS the object then? Is it just the module?
Object is a table. Any table technically so long as the table holds a function.
So, when would I never to use self then? I know I would use it to add a metatable, but would I do afterwards, because I’ve seen some scripts use self a TON of times.
It’s mostly used in OOP. Basically, if you pack all the functions that can use a table inside that same table, then you can just call the function on the table. It is shorthand so it technically never needs to be used, but it’s often helpful so you don’t have to type out the same thing over and over.
So if a table has properties like x, y and z and you have functions to interact with them (like Lerp) you can put the function inside the table and just call table:Lerp() to automatically pass table in.
So basically self = whatever called the function? For example,
function metatable.printSomething()
print(self.Data)--This prints the "Data" property of newTable?
end
newTable:printSomething()
Yup. Pretty much. Assuming metatable is a metatable to newTable.
you forgot to add the self
in the parameters