This is my first time posting here so sorry for any weird typos or anything in the post.
I’ve been dealing with an issue for a while where players data will save and randomly revert to an older version of their data a couple of servers later.
People have been saying that they will buy something ingame, and around an hour or two later their data reverts to an older version of their data.
The datastore script saves their data in a table whenever they leave and retrieves it when they join
local function Retrv()
Key = DataStore:GetAsync(ID)
if Key then
local Suc, Err = pcall(function()
for _, Targ in pairs(Inv:GetDescendants()) do if Targ:GetAttribute("ObjName") == nil then if Targ:IsA("StringValue") or Targ:IsA("NumberValue") or Targ:IsA("BoolValue") then
if Key[Targ.Name] and Targ:GetAttribute("ObjName") == nil then
Targ.Value = Key[Targ.Name]
end
end
end end
end)
if Err then Player:Kick("Data failed to load.") end
if Suc then GotData = true end
else
Values = {}
for i, v in pairs(Inv:GetDescendants()) do if v:IsA("StringValue") or v:IsA("NumberValue") or v:IsA("BoolValue") then
Values[v.Name] = v.Value
end end
DataStore:SetAsync(id,Values)
GotData = true
end
end
And the data saving function is
local function SAVELEAVE()
local VValues = {}
if Inv and Inv:FindFirstChild("Kaiju") then
for i, v in pairs(Inv:GetDescendants()) do if v:IsA("StringValue") or v:IsA("NumberValue") or v:IsA("BoolValue") then
if v and v:GetAttribute("ObjName") == nil and v.Value then
VValues[v.Name] = v.Value
end
end end
DataStore:SetAsync(ID,VValues)
repeat
task.wait()
local Succ,Err = pcall(function()
DataStore:SetAsync(ID,VValues)
end) if Succ then Success = true end
until Success == true
print("saved")
end
end
I’ve been trying on my own for a long time to try and fix this but I have no clue what causes their data to revert to an older version, and auto saving+saving when they leave doesn’t fix it