__newindex not invoking despite table value being changed?

local payloadInfo = {
	currentPosition = 1,
	currentTween = 0,
	payloadOwner = 0,
	playerInRange = 0
} 

local payloadMetatable = {
	__newindex = function(Table, Key)
		print("hello")
	end
}
setmetatable(payloadInfo, payloadMetatable)



payloadInfo.currentPosition = 5

As title states, I had it working a second ago but all of a sudden it’s just stopped working so I can imagine it’s something small, not too sure though, any help appreciated.

Since payloadInfo.currentPosition isn’t nil, it doesn’t invoke the __newindex method, so either:
A. Just run the newindex function whenever you change the property manually.
B. Create a “fake table” that gets indexed to make __newindex works.

Could you be kind enough as to provide a short snippet of an example?

I believe there was a module that did this, but here’s an example.

local fakeTable = {}
local realTable = {
    gaming = true
}
setmetatable(fakeTable, {
     __newindex = function(table, index, value)
       realTable[index] = value
       -- Do what you need to do when current position changes --
    end,
    __index = function(table, index)
        return realTable[index]
    end
})
fakeTable.currentPosition = 5

When you assign a value to an absent index in a table and if the table has a metamethod attached to it, then the interpreter looks for a __newindex metamethod: If there is one, the interpreter calls it instead of making the assignment
This is where you can get the full info:.
https://www.lua.org/pil/13.4.2.html

Appreciate that, I’d mark this as a solution too if I could as it cleared a lot of things up, thanks guys.