Hello, so I am creating a resource system where every resource will have its own seperate health n stuff like that but the problem is that, when I am trying to change the health after I created the object it isnt invoking the metamthod __newindex but weirdly enough it is actually changing the value though
local Resources = workspace.Resources
local ResourceManager = {}
ResourceManager.__newindex = function(self,index,value)
if index == "Health" then
print("Health value changed to "..value)
end
rawset(self,index,value)
end
function ResourceManager.new(Instance)
local self = setmetatable({}, ResourceManager)
self.Instance = Instance
self.Health = 100
return self
end
for _, model in ipairs(Resources:GetChildren()) do
local newResource = ResourceManager.new(model)
task.wait(1)
newResource.Health = 0 -- This isnt invoking the metamethod
end
return ResourceManager