So I’m trying to make a pretty hefty datastore for a game I’m working on. I had to remake the entire thing because I forgot roblox couldn’t save dictionaries, so I started remaking it and I’ve reworked most of the problem spots, but it gives me the same error. I can’t find where there would be an instance of a dictionary, unless doing something like
Table["SaveSlot1"] = 1
is considered a dictionary.
So I need help figuring out where the problem is here, aka where the datastore table becomes a dictionary.
Here’s the code
_G.Save = function(player, hrp)
local chr = player.Character
local Table = {
Saves = 0,
}
if player.Ingame.Value == true then
player.Data.Saves["SaveSlot"..player.SelectedSlot.Value].Location.Value = hrp.CFrame
player.Data.Saves["SaveSlot"..player.SelectedSlot.Value].CurrentHealth.Value = chr:FindFirstChildWhichIsA("Humanoid").Health
end
for i, v in pairs(player.Data.Saves:GetChildren()) do
Table.Saves = Table.Saves + 1
for e, r in pairs(SaveVals) do
if e == "Location" then
local cf = v[e].Value
local SAC, ERA = pcall(function()
Datastore:SetAsync(player.UserId.."-SSCF_"..Table.Saves,{cf:GetComponents()})
end)
if ERA then error("Location Saving Error: "..ERA) end
elseif e == "Primary" then
else
Table["SaveSlot"..Table.Saves.."-"..e] = v[e].Value
end
end
local InvTable = {}
for _, item in pairs(v.Inventory:GetChildren()) do
if item:FindFirstChild("Physical") ~= nil then
InvTable[item.Name] = "|Level:"..item.Value.."-Physical:"..item.Physical.Value.."-Magic:"..item.Magic.Value.."-Fire:"..item.Fire.Value.."-Lightning:"..item.Lightning.Value.."-Holy:"..item.Holy.Value.."-Critical:"..item.Critical.Value
else
InvTable[item.Name] = item.Value
end
end
local SAC, ERA = pcall(function()
Datastore:SetAsync(player.UserId.."-SS_"..Table.Saves,InvTable)
end)
if ERA then error("Inventory Saving Error: "..ERA) end
end
-- Main Datastore
local MainS, MainE = pcall(Datastore.SetAsync, Datastore, player.UserId, Table)
if MainS then
print("Successfully Saved Main Data For "..player.Name)
else
error(MainE) -- Error saving
end
-- Alpha/Beta Datastore
local s, e = pcall(function()
Datastore:SetAsync(player.UserId.."-alpha",player.Alpha.Value)
Datastore:SetAsync(player.UserId.."-beta",player.Beta.Value)
end)
if s then
print("Successfully saved "..player.Name.."'s data")
end
if e then
print(e)
end
end
I commented where the error pcall was displaying, so it’s clearly an issue with saving the main data.