__index and __newindex are only fired if the element does not already exist in the table. You’re going to need a proxy table if you want the behavior that you’re expecting
The majority of scripts emulate these metamethods (table index/table assignment) via getter/setter functions.
local plrStats = {
["comboCounter"] = 0,
}
local function getCombo()
return plrStats.comboCounter
--Add additional code here.
end
local function setCombo(valueIncrement)
assert(type(valueIncrement) == "number")
plrStats.comboCounter += valueIncrement
--Add additional code here.
end