What would be the best way to store lots of different kinds a data? I am making a game, and so far it has, regular stats, Magic, Guardians, Quests, and Settings. I am wanting to make all these save, but the system I have now is not very efficient and data loss sometimes occurs. Right now I use one DataStore with multiple different keys for the types of data, so there is a different key to run through for whatever data I want to access. I did not get to the saving the Quests or Settings due to me not wanting to waste time on a not effective save system.
The code I currently have for saving:
if plr:FindFirstChild("leaderstats") then
local key = "key-"..plr.userId
local Temp = game.Workspace:FindFirstChild(plr.Name .. "'s Temples")
Temp:Destroy()
local load = {plr.Stats:FindFirstChild("Holyness").Value,game.ReplicatedStorage.leaderstats:FindFirstChild(plr.Name):FindFirstChild("Level").Value,plr.Stats:FindFirstChild("Gain").Value,
plr.Stats:FindFirstChild("Wait").Value,0,plr.Stats:FindFirstChild("Points").Value,0,0,0,0,plr.Stats:FindFirstChild("PDamage").Value,0,
plr.Stats:FindFirstChild("Walk").Value,plr.Stats:FindFirstChild("Jump").Value,plr.Stats:FindFirstChild("Temples").Value,
plr.Stats:FindFirstChild("Bubbles").Value,plr.Stats:FindFirstChild("AddPoints").Value,plr.Stats:FindFirstChild("RP").Value,
plr.Stats:FindFirstChild("Tut").Value,game.ReplicatedStorage.leaderstats:FindFirstChild(plr.Name):FindFirstChild("Rebirths").Value,plr.Stats:FindFirstChild("LevelReload").Value,
plr.Stats:FindFirstChild("GodPoints").Value,plr.Stats:FindFirstChild("Sacrifices").Value}
DataStore:SetAsync(key,load)
local GodPower = plr.Stats.GodPower
OrderedDataStore:SetAsync(plr.UserId,GodPower.Value)
local skillfolder = plr.Magics
local MasterTable = {}
for _, skills in pairs(skillfolder:GetChildren()) do
local SkillsTable = {}
SkillsTable.SkillName = skills.Name
SkillsTable.SkillValue = skills.Value
MasterTable[#MasterTable + 1] = SkillsTable
end
DataStore:SetAsync(plr.UserId, MasterTable)
local petfolder = plr.Pets
local MasterTable2 = {}
for _, skills in pairs(petfolder:GetChildren()) do
local PetsTable = {}
PetsTable.PetName = skills.Name
PetsTable.PetValue = skills.Value
MasterTable2[#MasterTable2 + 1] = PetsTable
end
local key2 = plr.UserId .. "Pet"
DataStore:SetAsync(key2, MasterTable2)
local key3 = plr.UserId .. "Tag"
DataStore:SetAsync(key3, {plr.NameTag.Value})
InviteData:SetAsync(plr.UserId, plr.Stats.Invites.Value)
end
pcall(function()
game.ReplicatedStorage.leaderstats:FindFirstChild(plr.Name):Destroy()
end)

1 comment
It's best to upload all Data in an array to lower potential exhaust issues.