Heya, I have just now encountered this error that (I assume) prevents data from saving as since it started showing up data stopped saving.
I have looked at other posts with this error but I did not understand a single thing.
Code:
FUNCTION 1: Get default data.
function module:GetDefaultData()
return {
["Costumes"] = {
["Dan"] = "false",
["Alex"] = "false",
["Emma"] = "false",
["Princess"] = "false",
["Betty"] = "false",
["Matilda"] = "false",
["Demon"] = "false",
["Fairy"] = "false",
["Angel"] = "false",
["Nephalem"] = "false",
["Emotimask Derpy"] = "false",
["Emotimask Cute"] = "false",
["Emotimask Smiley"] = "false",
["Candy Corn"] = "false",
},
["Currencies"] = {
["Candy"] = 0
},
["EverPlayed"] = "false",
["Current Costume"] = "",
["Current BodyType"] = "",
["Quests"] = {
["Paranormal Hunter"] = {
["Status"] = nil,
["Progress"] = nil,
["Cooldown"] = 0,
},
["Letter"] = {
["Status"] = nil,
["Progress"] = nil,
["Cooldown"] = 0,
},
},
}
end
FUNCTION 2: Check if data has changed since last time (don’t think it’s related but could it started happening when I implemented this into the script).
function module.Check(Data)
local DefaultData = module:GetDefaultData()
local function LoopThroughTable(Table,CompareTable)
for Key,Value in pairs (Table) do
if Data[Key] == nil then
Data[Key] = Value
end
if type(Value) == "table" then
for Key1,Value in pairs (Table) do
if Data[Key][Key1] == nil then
Data[Key][Key1] = Value
end
if type(Value) == "table" then
for Key2,Value in pairs (Table) do
if Data[Key][Key1][Key2] == nil then
Data[Key][Key1][Key2] = Value
end
end
end
end
end
end
end
LoopThroughTable(DefaultData,Data)
end
FUNCTION 3: Saving the data
function module.SaveData(client)
if module.sessionData[client.UserId] then
local success,errormessage
local tries = 0
repeat
success,errormessage = pcall(function()
DataStore:UpdateAsync(client.UserId, function()
return module.sessionData[client.UserId]
end)
end)
if errormessage ~= nil then
wait(6)
tries += 1
end
until success or tries >= 2
if tries >= 2 then
print(errormessage," if you see this: take a screenshot and report to the discord server")
end
module.sessionData[client.UserId] = nil
end
end
Any help is appreciated!