The community of my game have been reporting data rollbacks(so the data goes back). I think it has to be the backup taking action and i think there is something wrong with data structure of my code because no one else is having this issue. I think it has something to do with combining the data but i dont know here is the code:
local DataStoreService = game:GetService("DataStoreService")
local ServerScriptStorage = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MemoryStorage = game:GetService("MemoryStoreService")
local PlayerProcessingData_SortedMap_Name = "Player_ProcessingData"
local PlayerProcessingData_SortedMap = MemoryStorage:GetSortedMap(PlayerProcessingData_SortedMap_Name)
local DataStore2 = require(ServerScriptStorage.Modules:WaitForChild("DataStore2"))
local UserDataStoreName = "UserDataStore"
DataStore2.Combine(UserDataStoreName, "Stats", "GunstoreGuns", "GunstoreAttachments")
local function SetupUserData()
local userData = {
Stats = {},
GunstoreGuns = {},
GunstoreAttachments = {{}}
}
return userData
end
game.Players.PlayerAdded:Connect(function(player)
local PlayerProcessingData
local succes2, result2 = pcall(function()
PlayerProcessingData = PlayerProcessingData_SortedMap:GetAsync(player.UserId)
end)
if succes2 and PlayerProcessingData then
if PlayerProcessingData ~= nil then
player:Kick("You was rejoining to fast, you would've lost your data. Join back in 5 to 40 seconds, if still not working CONTACT US")
return
end
end
------------------------------------------------------------------------DATA VALUES, CASH, LEVELS
local DataValues = Instance.new("Folder", player)
DataValues.Name = "DataValues"
local CashValue = Instance.new("NumberValue", DataValues)
CashValue.Name = "Cash"
local LevelValue = Instance.new("NumberValue", DataValues)
LevelValue.Name = "Level"
local EXPValue = Instance.new("NumberValue", DataValues)
EXPValue.Name = "EXP"
--------------------------------------------------------------------------TOOLS, GUNSTORE
local GunstoreGunsOwnedValues = Instance.new("Folder", player)
GunstoreGunsOwnedValues.Name = "GunstoreGunsOwnedValues"
local AttachmentOwnedValues = Instance.new("Folder", GunstoreGunsOwnedValues)
AttachmentOwnedValues.Name = "Attachments"
-----
local Plr_Data = DataStore2(UserDataStoreName, player):Get(SetupUserData())
local data
local StatsData = DataStore2("Stats", player)
local GunstoreAttachments_Data = DataStore2("GunstoreAttachments", player)
local GunstoreGuns_Data = DataStore2("GunstoreGuns", player)
if StatsData:Get(Plr_Data.Stats).Cash then
CashValue.Value = StatsData:Get(Plr_Data.Stats).Cash
end
if StatsData:Get(Plr_Data.Stats).Level ~= nil and StatsData:Get(Plr_Data.Stats).Level >= 1 then
LevelValue.Value = StatsData:This text will be hiddenGet(Plr_Data.Stats).Level
EXPValue.Value = StatsData:Get(Plr_Data.Stats).EXP
elseif StatsData:Get(Plr_Data.Stats).Level == nil or StatsData:Get(Plr_Data.Stats).Level == 0 then
LevelValue.Value = 1
end
if GunstoreGuns_Data:Get(Plr_Data.GunstoreGuns) then
for i, v in pairs(GunstoreGuns_Data:Get(Plr_Data.GunstoreGuns)) do
local GunStoreGunOwnedValue = Instance.new("StringValue", GunstoreGunsOwnedValues)
GunStoreGunOwnedValue.Name = ""..v
GunStoreGunOwnedValue.Value = ""..v
end
end
if GunstoreAttachments_Data:Get(Plr_Data.GunstoreAttachments[1]) then
for i, v in pairs(GunstoreAttachments_Data:Get(Plr_Data.GunstoreAttachments)[1]) do
local AttachmentOwnedValuesString = Instance.new("StringValue", AttachmentOwnedValues)
AttachmentOwnedValuesString.Name = ""..v.Attachment
AttachmentOwnedValuesString.Value = ""..v.Gun
end
end
end)