The title explains all, I'm confused with the usage of "this".
this
is a keyword in most Object-Oriented Programming (OOP) contexts. It refers to the individual instance object of a class. Lua actually has a version of this feature, called self
which works in the exact same way (Lua isn't an OOP language, but it is designed to support OOP concepts). For example...
-- Dog class local Dog = {} -- Method of Dog class: bark function Dog:bark() -- Increment number of barks within dog instance self.barks = self.barks + 1 -- ... end
In Lua, this
is not a keyword. Rather, it's just an ordinary variable name. Someone may call a variable this
if they're lazy, if the name of the variable doesn't matter, or perhaps if they're trying to emulate an OOP concept to make it look more familiar or conventional.
script
is a keyword in ROBLOX's version of Lua. It refers to the actual script object in the game that the code is running inside of. For example, if you have your explorer window open with a script somewhere in your game, with this code inside of it:
script:Destroy()
...and you run this code, you will promptly see the script object in your game disappear. The script
keyword is usually just used to access descendants or children that may exist in that directory.