What’s the best way to implement a PlayerData modulescript?
Currently I have something like
local DataModule = {}
Data = {}
function DataModule.AddData(Player)
Data[Player] = {
–Default data values go here
}
end
function DataModule.GetData(Player)
local PlayerData = Data[Player]
if PlayerData then return PlayerData end
end
function DataModule.SetData(Player, Key, Subkey, NewValue)
local PlayerData = Data[Player]
if PlayerData then
Data[Player][Key][Subkey] = NewValue
else
warn(“PlayerData missing!”)
end
end
–So on and so forth
return DataModule
but I’m debating whether or not it’s just better to have
local DataModule = {}
DataModule.Data = {}
so I can just use that - no need for any functions.