It's meant to print('Changed') whenever the value is changed but it doesn't work
local function createValues(playername, self)
local newFolder = Instance.new('Folder')
local kills = Instance.new('IntValue')
local deaths = Instance.new('IntValue')
newFolder.Name = self.Properties.Name
newFolder.Parent = metaFolder
kills.Parent = newFolder
deaths.Parent = newFolder
kills.Name = 'Kills'
deaths.Name = 'Deaths'
end
local meta = {}
meta.__index = meta
function meta:New(playername)
local actualTable = {
Stats = {
Kills = 0,
Deaths = 0
},
Properties = {
Name = playername
}
}
local mainTable = setmetatable(actualTable, self)
mainTable.Stats.__add = function(tbl, key)
print(key)
end
createValues(playername, mainTable)
end
I tweaked the script a bit but it still doesn't seem to work. There are no errors and when I add to the metatable I'm doing this
childMeta[player].Stats.Kills += 3

2 comments
Can you elaborate on the script you gave above? Like, what does 'self' contain and what errors did you get? Also, I believe mainTable.Stats alone is not yet a metatable, so the function wouldn't work (assuming you're trying to do 'mainTable.Stats + playername' in that createValues function)
Okay I edited it