I have this metatable but currently it feels very barren and I feel like I could add more, this metatable by the way is used to handle economy for countries in my game. What else could I add to improve it
local gameObject = {}
gameObject.__index = gameObject
gameObject.Nations = game.Workspace.Nations
function gameObject:New()
local baseTable = setmetatable({}, self)
baseTable.__index = baseTable
return baseTable
end
return gameObject
also this is some OOP (Object Oriented Programming), and we don’t use BaseTable we use self most of the functions, I recommend this topic which explains everything about OOP
-- module:
local Object = {} -- Couldn't figure out what to call it
Object.__index = Object
Object.Nations = workspace.Nations
function Object.new()
local self = {}
-- code
return setmetatable(self, Object)
end
function Object:Destroy()
table.clear(self)
end
return Object
It would help if there was more code because I don’t know what this is for.
This is the serverscript I’m requiring it in if that helps
local object = require(game.ServerStorage.Object)
for _, country in ipairs(object.Nations:GetChildren()) do
if country:IsA("Folder") then
for _, province in ipairs(country.Provinces:GetChildren()) do
countryIncome = country:WaitForChild("Income")
countryIncome.Value = countryIncome.Value + 10
end
end
end