I’ve been having a lot of trouble trying to find a way to save a table from a module script into a server script datastore.
Is it even possible, if so how?
I wanna be able to save everything
Module Script with tables:
local SensitiveData = {
Upgrades = {
Chips = {
Factory = true,
Optimized = false,
Enhanced = false,
Recoded = false
},
Signals = {
Entry = true,
Mid = false,
High = false,
Deluxe = false
}
},
Class = {Ascension = false, CovenCode = false, Druidex = false, Pyramystic = false}
}
return SensitiveData
DataStore Server Script:
local DataModule = require(script.Parent.DataTable)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local aureus = Instance.new("NumberValue")
aureus.Name = "Aureus"
-- Move
leaderstats.Parent = player
aureus.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = experienceStore:GetAsync("playerdata_"..player.UserId)
end)
if success then
if data then
local aureusValue = data.aureusValue or 0
aureus.Value = aureusValue
print("Loaded data")
else
aureus.Value = 0
end
else
print("Error while data load")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local stats = player.leaderstats
local aureus = stats.Aureus
local data = {
aureusValue = aureus.Value,
upgrades = DataModule.Upgrades,
}
local success, errormessage = pcall(function()
experienceStore:SetAsync("playerdata_"..player.UserId, data)
end)
if success then
print("Player Data Saved")
else
print("Failed Save")
warn(errormessage)
end
end)