basicly I want many stats of the player to be in one table (like health...) in a module but in a normal table u cant detect if a value changes so im usign metatables but its not really working
I have this module script:
local module = {}
local rs = game:GetService("RunService")
local Values = {
["val1"] = false,
["val2"] = true
}
module.mt = {}
setmetatable(Values,module.mt)
print(module.mt)
module.SetValue = function (ValueName, NewValueValue)
if rs:IsServer() == true then
print(2)
module.mt[ValueName] = NewValueValue
end
end
return module
and this serverscrpt:
local module = require(game.ReplicatedStorage.Modules.ValueScript)
wait(1)
module.SetValue("val1",true)
print(module.mt)
wait(1)
but the table is empty until I change a value in it with: module.SetValue("val1",true)
so it prints:
20:54:34.262 {} - Server - ValueScript:14
20:54:35.265 2 - Server - ValueScript:18
20:54:35.265 ▼ {
["val1"] = true
} - Server - Script:7
why is that