✓ Accepted answer
This is a really big question. I will give a sort of broad answer, but take it as it is. OOP.
OOP does not make your code faster, in some cases it actually makes your code slower. However, it makes it prettier and in my opinion more organized.
By making things into custom "objects" and controlling how they are accessed using metatables, it is almost like being the designer.
For example, the front end result of using metatables to create OOP, might look like this:
local lib = require(script.lib)
local player = lib.player
local io = lib.io
local enum = lib.enum
player.StartedNewSession:Link(function(sessionNumber)
print(("%d has joined session: %d"):format(player.GameID, sessionNumber))
end)
io.Keyboard.Press:Link(function(key, gameMode)
if gameMode ~= enum.GameMode.Typing then
if key == enum.KeyboardKey.G then
print("You are a G!")
end
end
end)
I've created custom methods, events, libraries with new information to build off of.
In my opinion, doing things like above, making your scripts more natural for yourself to understand, is the key to positive continuous development flow, and outweighs any cons.
--
Metatables give extra functionality to tables, so much so that they become way more complex data structures, and possibilities become endless.
I recommend following through in learning.
1 comment
Metatables are best for OOP(Object-Oriented Programming), or even creating your own classes like CFrame's.