Need some help with proxy table

Hey guys, I made a proxytable so I know when something gets changed on my table;
though i’ve got an issue,
here’s a bit of the code;

local module = {}
local DSS = game:GetService("DataStoreService")
local https = game:GetService("HttpService")
local Datastore = DSS:GetDataStore("DATA - PlayerStorage V9")
local Market = game:GetService('MarketplaceService')
module.__index = module

function module.getplayer(plr)
	return module[plr] or module.new(plr)
end

function module.new(plr)
	assert(plr ~= nil,"plr's nil.")
	local Template = {
		ToSave = {
			-- stuff doesn't matters.
		};
		FinishedRace = false;
		InRace = false;
		GamepassOwneds = {

		}
	}
	local ProxyTable = setmetatable(module,{
		__index = function(self,i)
			if (self) then
				self['index']() -- Calls the function!
			end;
			return Template[i]
		end,
		__newindex = function(self,index,newvalue)
			if (self) then
				self['index']() -- Calls function
			end;
			Template[index] = newvalue;
		end,
	})
	local self = ProxyTable--(tmp,module)
	Template.Player = plr
	module[plr] = self
	return self
end

-- client updated info
function module:index()
	print(self) --- Outputs nil.
end;

return module

Basically, when self:index() is called it returns nil.
image

2 Likes

What i’m trying to know it’s just to know when __index gets fired at Template , so I decided to make a proxy but it didn’t worked as expected

1 Like

Just solved it on my own :smiley:

1 Like