Datastore2 not working?!

I have no idea what I am doing wrong AT ALL. But alot of players in my game will randomly lose data their save will be reverted to a previous one and I am legit lost.

(Keep in mind i’m teleporting players around constantly…)

There are no errors at all and I have looked over this code 100 times and found nothing…

Place 1:

(Loading)

Saving:

while module.Wait(1.75) do
		success,data = pcall(function()
			if game.ServerStorage.MatchSettings.IsCanada.Value == true then
				plr.MegaCard.Value = "Aurora"
				plr.MegaCard.Level.Value = plr.Level.Value
			end
			local boxes = {}
			local deck = {}
			local cards = {}
			local abletoget = {}
			local codes = {}
			local boosts = {}
			local tskins = {}
			for i,x in pairs(plr.TowerSkins:GetChildren()) do
				table.insert(tskins,x.Name)
			end
			for i,x in pairs(plr.Boosts:GetChildren()) do
				local tab = {
					BoostTime = x.Name,
					BoostName = x.BoostName.Value,
				}
				table.insert(boosts,tab)
			end
			for i,x in pairs(plr.Codes:GetChildren()) do
				table.insert(codes,x.Name)
			end
			for i,x in pairs(plr.AbleToGet:GetChildren()) do
				table.insert(abletoget,x.Name)
			end
			for i,x in pairs(plr.Boxes:GetChildren()) do
				local btab = {
					Name = x.Name,
					Finish = x.Finish.Value,
				}
				table.insert(boxes,btab)
			end
			for i,x in pairs(plr.Deck:GetChildren()) do
				local btab = {
					Name = x.Name,
					Level = x.Level.Value,
					Amount = x.Amount.Value,
					DebuffInfo = {Debuff = "Attack Speed",Percent = 8},
					AbilityInfo = {Ability = "LifeSteal",Percent = 8},
				}
				if x:FindFirstChild("StarCardInfo") then
					btab.DebuffInfo.Debuff = x.StarCardInfo.DebuffName.Value
					btab.DebuffInfo.Percent = x.StarCardInfo.DebuffPercent.Value
					btab.AbilityInfo.Ability = x.StarCardInfo.AbilityName.Value
					btab.AbilityInfo.Percent = x.StarCardInfo.AbilityPercent.Value
				else
					btab.AbilityInfo = nil
					btab.DebuffInfo = nil
				end
				table.insert(deck,btab)
			end
			for i,x in pairs(plr.Cards:GetChildren()) do
				local btab = {
					Name = x.Name,
					Level = x.Level.Value,
					Amount = x.Amount.Value,
					DebuffInfo = {Debuff = "Attack Speed",Percent = 8},
					AbilityInfo = {Ability = "LifeSteal",Percent = 8},
				}
				if x:FindFirstChild("StarCardInfo") then
					btab.DebuffInfo.Debuff = x.StarCardInfo.DebuffName.Value
					btab.DebuffInfo.Percent = x.StarCardInfo.DebuffPercent.Value
					btab.AbilityInfo.Ability = x.StarCardInfo.AbilityName.Value
					btab.AbilityInfo.Percent = x.StarCardInfo.AbilityPercent.Value
				else
					btab.AbilityInfo = nil
					btab.DebuffInfo = nil
				end
				table.insert(cards,btab)
			end
			local dquestdata = nil
			if plr.DailyQuest:FindFirstChildWhichIsA("Folder") then
				dquestdata = {
					OtherTime = plr.DailyQuest:FindFirstChildWhichIsA("Folder").Name,
					Challanges = {}
				}
				for i,x in pairs(plr.DailyQuest:GetChildren()) do
					local tabD = {
						Completed = x.CollectedReward.Value,
						Challange = x.ToDo:FindFirstChildWhichIsA("IntValue").Name,
						ChallangeAmount = x.ToDo:FindFirstChildWhichIsA("IntValue").Value,
						ChallangeDone = x.Completed:FindFirstChildWhichIsA("IntValue").Value,
						StarCard = false,
					}
					if x:FindFirstChild("StarQuest") then
						tabD.StarCard = true
					end
					table.insert(dquestdata.Challanges,tabD)
				end
			end
			local megacard = {"Tall Noob",0,0}
			if dataM ~= nil and dataM["MegaCardInfo"] ~= nil then
				megacard = dataM["MegaCardInfo"]
			end
			local tab = {
				Coins = plr.Coins.Value,
				Blocks = plr.Blocks.Value,
				TotalBoxes = plr.TotalBoxes.Value,
				Boxes = boxes,
				CurrentDeck = deck,
				Cards = cards,
				AbleToGet = abletoget,
				Bloxalians = plr.Bloxalians.Value,
				Bloxfield = plr.Bloxfield.Value,
				LostLimit = plr.LostLimit.Value,
				Level2 = plr.Level.Value,
				XP2 = plr.XP.Value,
				QuestData2 = dquestdata,
				Codes = codes,
				Boosts = boosts,
				LastSign = plr.LeaderboardSign.Value,
				MembershipTime = plr.CurrentMembership.Value,
				MissionFrozen = plr.MissionFrozen.Value,
				CanDuel = plr.CanDuel.Value,
				Wins = {Wins1v1 = plr["1v1Wins"].Value,Wins2v2 = plr["2v2Wins"].Value},
				Sets = {SetTag = plr.SetTag.Value,SetChar = plr.SetChar.Value,SetTroop = plr.SetTroop.Value},
				IsMusic = plr.CanMusic.Value,
				WeekendBoost = plr.WeekendBoost.Value,
				WinRewards = {Win1 = plr.WinRewards.Win1.Value,Win2 = plr.WinRewards.Win2.Value,Win3 = plr.WinRewards.Win3.Value,Win4 = plr.WinRewards.Win4.Value,Win5 = plr.WinRewards.Win5.Value,Win6 = plr.WinRewards.Win6.Value},
				CanShake = plr.CanShake.Value,
				CanQuality = plr.CanQuality.Value,
				MegaCardInfo = megacard,
				PurchasedMega2 = plr.PurchasedMega.Value,
				MOTD = "STAR",
				CurrentSkins = {plr.CurrentTowerSkins.LeftTower.Value,plr.CurrentTowerSkins.MiddleTower.Value,plr.CurrentTowerSkins.RightTower.Value},
				TowerSkins = tskins,
				StarterPackTime = plr.StarterPackTime.Value,
				CanCharacter = plr.CanCharacter.Value,
				MissionCanada = plr.MissionCanada.Value,
				CanLikes = plr.CanLikes.Value,
				StarCards = plr.StarCards.Value,
				CollectedRewards = plr.CollectedRewards.Value,
				MissionStar = plr.MissionStar.Value,
				MissionFrozenRound = plr.MissionFrozen.Round.Value
			}
			plrdata:Set(tab)
		end)

Place 2:

(Loading)

local plrdata = DataStore2("MainData", plr)
		plrdata:SetBackup(5)
		local success,data = pcall(function()
			local data = plrdata:Get()
			local possiblechalg = {}
			if data ~= nil then
				plr.Coins.Value = data.Coins
				plr.Blocks.Value = data.Blocks
				plr.TotalBoxes.Value = data.TotalBoxes
				for i,x in pairs(data.Boxes) do
					local box = Instance.new("Folder",plr.Boxes)
					box.Name = x.Name
					local finish = Instance.new("IntValue",box)
					finish.Name = "Finish"
					finish.Value = x.Finish
				end
				for i,x in pairs(data.CurrentDeck) do
					local card = Instance.new("Folder",plr.CurrentDeck)
					card.Name = x.Name
					local lvl = Instance.new("IntValue",card)
					lvl.Name = "Level"
					lvl.Value = x.Level
					local amount = Instance.new("IntValue",card)
					amount.Name = "Amount"
					amount.Value = x.Amount
					if x["DebuffInfo"] ~= nil then
						local fold = Instance.new("Folder",card)
						fold.Name = "StarCardInfo"
						local dName = Instance.new("StringValue",fold)
						dName.Name = "DebuffName"
						dName.Value = x.DebuffInfo.Debuff
						local dPercent = Instance.new("IntValue",fold)
						dPercent.Name = "DebuffPercent"
						dPercent.Value = x.DebuffInfo.Percent
						local AName = Instance.new("StringValue",fold)
						AName.Name = "AbilityName"
						AName.Value = x.AbilityInfo.Ability
						local APercent = Instance.new("NumberValue",fold)
						APercent.Name = "AbilityPercent"
						APercent.Value = x.AbilityInfo.Percent
					end
				end
				for i,x in pairs(data.Cards) do
					local card = Instance.new("Folder",plr.Cards)
					card.Name = x.Name
					local lvl = Instance.new("IntValue",card)
					lvl.Name = "Level"
					lvl.Value = x.Level
					local amount = Instance.new("IntValue",card)
					amount.Name = "Amount"
					amount.Value = x.Amount
					if x["DebuffInfo"] ~= nil then
						local fold = Instance.new("Folder",card)
						fold.Name = "StarCardInfo"
						local dName = Instance.new("StringValue",fold)
						dName.Name = "DebuffName"
						dName.Value = x.DebuffInfo.Debuff
						local dPercent = Instance.new("IntValue",fold)
						dPercent.Name = "DebuffPercent"
						dPercent.Value = x.DebuffInfo.Percent
						local AName = Instance.new("StringValue",fold)
						AName.Name = "AbilityName"
						AName.Value = x.AbilityInfo.Ability
						local APercent = Instance.new("NumberValue",fold)
						APercent.Name = "AbilityPercent"
						APercent.Value = x.AbilityInfo.Percent
					end
				end
				if data["AbleToGet"] ~= nil then
					for i,x in pairs(data.AbleToGet) do
						if plr.UnableToGet:FindFirstChild(x) then
							plr.UnableToGet[x]:Destroy()
						end
						local mod = Instance.new("Model")
						mod.Parent = plr.AbleToGet
						mod.Name = x
					end
				end
				if data["Bloxalians"] ~= nil then
					plr.Bloxalians.Value = data.Bloxalians
				end
				if data["Bloxfield"] ~= nil then
					plr.Bloxfield.Value = data.Bloxfield
				end
				if data["LostLimit"] ~= nil then
					plr.LostLimit.Value = data.LostLimit
				end
				if data["Level2"] ~= nil then
					plr.Level.Value = data.Level2
				end
				if data["XP2"] ~= nil then
					plr.XP.Value = data.XP2
				end
				if data["PurchasedMega2"] then
					plr.PurchasedMega.Value = data["PurchasedMega2"]
				end
				if data["Wins"] ~= nil then
					plr["1v1Wins"].Value = data.Wins.Wins1v1
					plr["2v2Wins"].Value = data.Wins.Wins2v2
				end
				if data["Sets"] ~= nil then
					plr.SetChar.Value = data.Sets.SetChar
					plr.SetTag.Value = data.Sets.SetTag
					plr.SetTroop.Value = data.Sets.SetTroop
				end
				if data["Codes"] ~= nil then
					for i,x in pairs(data.Codes) do
						local mod = Instance.new("Model",plr.Codes)
						mod.Name = x
					end
				end
				if data["Boosts"] ~= nil then
					for i,x in pairs(data.Boosts) do
						local fold = Instance.new("Folder",plr.Boosts)
						fold.Name = x.BoostTime
						local int = Instance.new("StringValue",fold)
						int.Name = "BoostName"
						int.Value = x.BoostName
					end
				end
				if data["LastSign"] ~= nil then
					plr.LeaderboardSign.Value = data["LastSign"]
				end
				if data["StarCards"] ~= nil then
					plr.StarCards.Value = data["StarCards"]
				end
				if data["MembershipTime"] ~= nil then
					plr.CurrentMembership.Value = data["MembershipTime"]
				end
				if data["MissionFrozen"] ~= nil then
					plr.MissionFrozen.Value = data["MissionFrozen"]
					if plr.MissionFrozen.Value == "Forgotten Desert" then
						plr.MissionFrozen.Value = "Mission1"
					end
				end
				if data["MissionStar"] ~= nil then
					plr.MissionStar.Value = data["MissionStar"]
					if plr.MissionStar.Value == "Forgotten Desert" then
						plr.MissionStar.Value = "Mission1"
					end
				end
				if data["MissionFrozenRound"] ~= nil then
					plr.MissionFrozen.Round.Value = data["MissionFrozenRound"]
				end
				if data["MissionCanada"] ~= nil then
					plr.MissionCanada.Value = data["MissionCanada"]
					if plr.MissionCanada.Value == "Forgotten Desert" then
						plr.MissionCanada.Value = "Mission1"
					end
				end
				if data["StarterPackTime"] ~= nil then
					plr.StarterPackTime.Value = data["StarterPackTime"]
				end
				if data["IsMusic"] ~= nil then
					plr.CanMusic.Value = data["IsMusic"]
				end
				if data["IsMusic"] ~= nil then
					plr.CanMusic.Value = data["IsMusic"]
				end
				if data["CanDuel"] ~= nil then
					plr.CanDuel.Value = data["CanDuel"]
				end
				if data["CanQuality"] ~= nil then
					plr.CanQuality.Value = data["CanQuality"]
				end
				if data["WeekendBoost"] ~= nil then
					plr.WeekendBoost.Value = data["WeekendBoost"]
				end
				if data["MOTD"] ~= nil then
					plr.MOTD.Value = data["MOTD"]
				end
				if data["WinRewards"] then
					plr.WinRewards.Win1.Value = data["WinRewards"].Win1
					plr.WinRewards.Win2.Value = data["WinRewards"].Win2
					plr.WinRewards.Win3.Value = data["WinRewards"].Win3
					plr.WinRewards.Win4.Value = data["WinRewards"].Win4
					plr.WinRewards.Win5.Value = data["WinRewards"].Win5
					plr.WinRewards.Win6.Value = data["WinRewards"].Win6
				end
				if data["CanShake"] ~= nil then
					plr.CanShake.Value = data.CanShake
				end
				if data["CanCharacter"] ~= nil then
					plr.CanCharacter.Value = data.CanCharacter
				end
				if data["CanLikes"] ~= nil then
					plr.CanLikes.Value = data.CanLikes
				end
				if data["MegaCardInfo"] ~= nil then
					plr.MegaCard.Value = data["MegaCardInfo"][1]
					plr.MegaCard.Level.Value = data["MegaCardInfo"][2]
					plr.MegaCard.Amount.Value = data["MegaCardInfo"][3]
					local x = data["MegaCardInfo"]
					if x["DebuffInfo"] ~= nil then
						local fold = Instance.new("Folder",plr.MegaCard)
						fold.Name = "StarCardInfo"
						local dName = Instance.new("StringValue",fold)
						dName.Name = "DebuffName"
						dName.Value = x.DebuffInfo.Debuff
						local dPercent = Instance.new("IntValue",fold)
						dPercent.Name = "DebuffPercent"
						dPercent.Value = x.DebuffInfo.Percent
						local AName = Instance.new("StringValue",fold)
						AName.Name = "AbilityName"
						AName.Value = x.AbilityInfo.Ability
						local APercent = Instance.new("NumberValue",fold)
						APercent.Name = "AbilityPercent"
						APercent.Value = x.AbilityInfo.Percent
					end
				end
				if data["CollectedRewards"] ~= nil then
					plr.CollectedRewards.Value = data["CollectedRewards"]
				end
				if data["CurrentSkins"] then
					plr.CurrentTowerSkins.LeftTower.Value = data["CurrentSkins"][1]
					plr.CurrentTowerSkins.MiddleTower.Value = data["CurrentSkins"][2]
					plr.CurrentTowerSkins.RightTower.Value = data["CurrentSkins"][3]
				end
				if data["TowerSkins"] then
					for i,x in pairs(data["TowerSkins"]) do
						if not plr.TowerSkins:FindFirstChild(x) then
							local mod = Instance.new("Model",plr.TowerSkins)
							mod.Name = x
						end
					end
				end
				
				for i,x in pairs(game.ServerStorage.QuestChallanges:GetChildren()) do
					if x:FindFirstChild("BloxalianLimit") and plr.Bloxalians.Value >= x.BloxalianLimit.Value then
						table.insert(possiblechalg,x)
					elseif not x:FindFirstChild("BloxalianLimit") then
						table.insert(possiblechalg,x)
					end
				end
				if data["QuestData2"] ~= nil then
					if tonumber(data.QuestData2.OtherTime) <= os.time() then
						local amount = 2
						if plr.CurrentMembership.Value > os.time() then
							amount = 3
						end
						for i=1,amount do
							local dfold = game.ServerStorage.QuestDefault:Clone()
							dfold.Parent = plr.DailyQuest
							dfold.Name = tostring(os.time()+85800)
							local challangeN = math.random(1,#possiblechalg)
							local challange = possiblechalg[challangeN]
							table.remove(possiblechalg,challangeN)
							local val = Instance.new("IntValue")
							val.Parent = dfold.ToDo
							val.Name = challange.Name
							val.Value = math.random(challange.Min.Value,challange.Max.Value)
							local max = 24
							if plr.CurrentMembership.Value > os.time() then
								max = 20
							end
							if math.random(1,max) == 1 then
								val.Value = val.Value * 3
								local foldS = Instance.new("Folder",dfold)
								foldS.Name = "StarQuest"
							end
							local val2 = Instance.new("IntValue")
							val2.Parent = dfold.Completed
							val2.Name = val.Name
						end
					else
						for i,x in pairs(data.QuestData2.Challanges) do
							if game.ServerStorage.QuestChallanges:FindFirstChild(x.Challange) then
								local dfold = game.ServerStorage.QuestDefault:Clone()
								dfold.Parent = plr.DailyQuest
								dfold.Name = data.QuestData2.OtherTime
								local val = Instance.new("IntValue")
								val.Parent = dfold.ToDo
								val.Name = x.Challange
								val.Value = x.ChallangeAmount
								local val2 = Instance.new("IntValue")
								val2.Parent = dfold.Completed
								val2.Name = val.Name
								val2.Value = x.ChallangeDone
								dfold.CollectedReward.Value = x.Completed
								if x["StarCard"] ~= nil and x.StarCard == true then
									local foldS = Instance.new("Folder",dfold)
									foldS.Name = "StarQuest"
								end
							end
						end
					end
				else
					local amount = 2
					if plr.CurrentMembership.Value > os.time() then
						amount = 3
					end
					for i,x in pairs(game.ServerStorage.QuestChallanges:GetChildren()) do
						if x:FindFirstChild("BloxalianLimit") and plr.Bloxalians.Value >= x.BloxalianLimit.Value then
							table.insert(possiblechalg,x)
						elseif not x:FindFirstChild("BloxalianLimit") then
							table.insert(possiblechalg,x)
						end
					end
					for i=1,amount do
						local dfold = game.ServerStorage.QuestDefault:Clone()
						dfold.Parent = plr.DailyQuest
						dfold.Name = tostring(os.time()+85800)
						local challangeN = math.random(1,#possiblechalg)
						local challange = possiblechalg[challangeN]
						table.remove(possiblechalg,challangeN)
						local val = Instance.new("IntValue")
						val.Parent = dfold.ToDo
						val.Name = challange.Name
						val.Value = math.random(challange.Min.Value,challange.Max.Value)
						local max = 24
						if plr.CurrentMembership.Value > os.time() then
							max = 20
						end
						if math.random(1,max) == 1 then
							val.Value = val.Value * 3
							local foldS = Instance.new("Folder",dfold)
							foldS.Name = "StarQuest"
						end
						local val2 = Instance.new("IntValue")
						val2.Parent = dfold.Completed
						val2.Name = val.Name
					end
				end
			else
				local quality = game.ReplicatedStorage.Events.GetGraphics:InvokeClient(plr)
				if quality == Enum.SavedQualitySetting.QualityLevel6 or quality == Enum.SavedQualitySetting.QualityLevel7 or quality == Enum.SavedQualitySetting.QualityLevel8 or quality == Enum.SavedQualitySetting.QualityLevel9 or quality == Enum.SavedQualitySetting.QualityLevel10 then
					plr.CanQuality.Value = true
				else
					plr.CanQuality.Value = false
				end
				local card = Instance.new("Folder",plr.CurrentDeck)
				card.Name = "Guest"
				local lvl = Instance.new("IntValue",card)
				lvl.Name = "Level"
				lvl.Value = 0
				local amount = Instance.new("IntValue",card)
				amount.Name = "Amount"
				amount.Value = 5
				local box2 = game.ServerStorage["Epic Box"]:Clone()
				box2.Parent = plr.Boxes
				plr.Boxes["Epic Box"].Finish.Value = os.time()
				
				local amount = 2
				if plr.CurrentMembership.Value > os.time() then
					amount = 3
				end
				
				for i,x in pairs(game.ServerStorage.QuestChallanges:GetChildren()) do
					if x:FindFirstChild("BloxalianLimit") and plr.Bloxalians.Value >= x.BloxalianLimit.Value then
						table.insert(possiblechalg,x)
					elseif not x:FindFirstChild("BloxalianLimit") then
						table.insert(possiblechalg,x)
					end
				end
				
				for i=1,amount do
					local dfold = game.ServerStorage.QuestDefault:Clone()
					dfold.Parent = plr.DailyQuest
					dfold.Name = tostring(os.time()+85800)
					local challangeN = math.random(1,#possiblechalg)
					local challange = possiblechalg[challangeN]
					table.remove(possiblechalg,challangeN)
					local val = Instance.new("IntValue")
					val.Parent = dfold.ToDo
					val.Name = challange.Name
					val.Value = math.random(challange.Min.Value,challange.Max.Value)
					local max = 24
					if plr.CurrentMembership.Value > os.time() then
						max = 21
					end
					if math.random(1,max) == 1 then
						val.Value = val.Value * 3
						local foldS = Instance.new("Folder",dfold)
						foldS.Name = "StarQuest"
					end
					local val2 = Instance.new("IntValue")
					val2.Parent = dfold.Completed
					val2.Name = val.Name
				end
			end
			if plr.StarterPackTime.Value == 0 then
				plr.StarterPackTime.Value = os.time()+172800
			end
			local cards = {}
			for i,x in pairs(plr.Cards:GetChildren()) do
				local able = true
				for v,r in pairs(cards) do
					if r.Name == x.Name then
						able = false
						x:Destroy()
					end
				end
				if able == true then
					table.insert(cards,x)
				end
			end
			for i,x in pairs(plr.CurrentDeck:GetChildren()) do
				local able = true
				for v,r in pairs(cards) do
					if r.Name == x.Name then
						able = false
						x:Destroy()
					end
				end
				if able == true then
					table.insert(cards,x)
				end
			end
		end)

(Saving is the exact same…)

ANY HELP IS GREATLY APPRECIATED!

Are you using CombinedDataStores? It is recommended to do so as using the master key behaviour can be unpredictable.

https://kampfkarren.github.io/Roblox/api/

Yes I am combining them.

local DataStore2 = require(game.ServerStorage.Modules.MainModule)

DataStore2.Combine("DATA", "MainData")

It seems to happen very randomly and I have no idea why…