Data Store Request was added to queue

I just noticed that data on my game hasn’t been saving and there was a warning saying “Data store request was added to queue.” screenshot below.

and I have no idea how to fix it. My Data Store script is below:

local DataStore = game:GetService("DataStoreService")
local PolicyService = game:GetService("PolicyService")
local standdata = DataStore:GetDataStore("Stand2")
local moneydata = DataStore:GetDataStore("Cash2")
local diamonddata = DataStore:GetDataStore("Diamonds2")
local coindata = DataStore:GetDataStore("MasteryCoins2")
local xpdata = DataStore:GetDataStore("XP2")
local slot1data = DataStore:GetDataStore("Slot4")
local slot2data = DataStore:GetDataStore("Slot5")
local slot3data = DataStore:GetDataStore("Slot6")

local RunService = game:GetService("RunService")

game.Players.PlayerAdded:Connect(function(player)
	local playerKey = "Player_" .. player.UserId
	
	--Leaderstats
	local data = Instance.new("Folder", player)
	data.Name = "Data"
	
	--Stand	
	local stand = Instance.new("IntValue", data)
	stand.Name = "Stand"
	
	--Check their stand
	local myStand
	
	local success, err = pcall(function()
		myStand = standdata:GetAsync(playerKey)
	end)
	
	if success then
		stand.Value = myStand
	else
		stand.Value = 1
	end
	stand.Value = standdata:GetAsync(player.UserId) or 1
	--Save their stand
	standdata:SetAsync(player.UserId, stand.Value)
	stand.Changed:connect(function()
		print("Saving data...")
		standdata:SetAsync(player.UserId, stand.Value)	
		print(player.UserId.."'s data has been saved!")	
	end)
	
	--game.OnClose = function()
		--standdata:SetAsync(player.UserId, stand.Value)	
		--print(player.UserId.."'s data has been saved!")	
		--end

	
	
	--TRADING DATA	
	
	local ableToTrade = Instance.new("BoolValue")
	ableToTrade.Name = "TradingEnabled"
	ableToTrade.Value = PolicyService:GetPolicyInfoForPlayerAsync(player).IsPaidItemTradingAllowed
	ableToTrade.Parent = data
	
	--local stand = Instance.new("IntValue", data)
	--stand.Name = "Trading"
	

	--Money
	local money = Instance.new("IntValue")
	money.Parent = data
	money.Name = "Money"
	--Check their money
	local myMoney
	
	local success, err = pcall(function()
		myMoney = moneydata:GetAsync(playerKey)
	end)
	
	if success then
		money.Value = myMoney
	else
		money.Value = 100
	end
	money.Value = moneydata:GetAsync(player.UserId) or 100
	--Save their money
	moneydata:SetAsync(player.UserId, money.Value)
	money.Changed:connect(function()
		print("Saving data...")
		moneydata:SetAsync(player.UserId, money.Value)	
		print(player.UserId.."'s data has been saved! (Cash)")	
	end)
	
		--Diamonds
	local Diamonds = Instance.new("IntValue")
	Diamonds.Parent = data
	Diamonds.Name = "Diamonds"
	--Check their Diamonds
	local myDiamonds
	
	local success, err = pcall(function()
		myDiamonds = diamonddata:GetAsync(playerKey)
	end)
	
	if success then
		Diamonds.Value = myDiamonds
	else
		Diamonds.Value = 0
	end
	Diamonds.Value = diamonddata:GetAsync(player.UserId) or 0
	--Save their money
	diamonddata:SetAsync(player.UserId, Diamonds.Value)
	Diamonds.Changed:connect(function()
		print("Saving data...")
		diamonddata:SetAsync(player.UserId, Diamonds.Value)	
		print(player.UserId.."'s data has been saved! (Diamonds)")	
	end)
	
	
		--MasteryCoins
	local coins = Instance.new("IntValue")
	coins.Parent = data
	coins.Name = "coins"
	--Check their Diamonds
	local myCoins
	
	local success, err = pcall(function()
		myCoins = coindata:GetAsync(playerKey)
	end)
	
	if success then
		coins.Value = myCoins
	else
		coins.Value = 0
	end
	coins.Value = coindata:GetAsync(player.UserId) or 0
	--Save their money
	coindata:SetAsync(player.UserId, coins.Value)
	coins.Changed:connect(function()
		print("Saving data...")
		coindata:SetAsync(player.UserId, coins.Value)	
		print(player.UserId.."'s data has been saved! (Mastery Coins)")	
	end)
	
		--Experience
	local experience = Instance.new("IntValue")
	experience.Parent = data
	experience.Name = "XP"
	--Check their experience
	local myExperience
	
	local success, err = pcall(function()
		myExperience = xpdata:GetAsync(playerKey)
	end)
	
	if success then
		experience.Value = myExperience
	else
		experience.Value = 0
	end
	experience.Value = xpdata:GetAsync(player.UserId) or 0
	--Save their money
	xpdata:SetAsync(player.UserId, experience.Value)
	experience.Changed:connect(function()
		print("Saving data...")
		xpdata:SetAsync(player.UserId, experience.Value)	
		print(player.UserId.."'s data has been saved! (Experience)")	
	end)
	
	-- Slots made by sfant43/SirWolk
	local Slot1 = Instance.new("IntValue"); Slot1.Name = "Slot1"; Slot1.Parent = data
	local Slot2 = Instance.new("IntValue"); Slot2.Name = "Slot2"; Slot2.Parent = data
	local Slot3 = Instance.new("IntValue"); Slot3.Name = "Slot3"; Slot3.Parent = data
	
	local mySlot1
	local mySlot2
	local mySlot3
	
	local success1, err = pcall(function()
		mySlot1 = slot1data:GetAsync(playerKey)
	end)
	
	if success1 then
		Slot1.Value = mySlot1
	else
		Slot1.Value = 1
	end
	Slot1.Value = slot1data:GetAsync(player.UserId) or 1
	slot1data:SetAsync(player.UserId, Slot1.Value)
	
	local success2, err = pcall(function()
		mySlot2 = slot2data:GetAsync(playerKey)
	end)
	
	if success2 then
		Slot2.Value = mySlot2
	else
		Slot2.Value = 1
	end
	
	Slot2.Value = slot2data:GetAsync(player.UserId) or 1
	slot2data:SetAsync(player.UserId, Slot2.Value)
	
	local success3, err = pcall(function()
		mySlot3 = slot3data:GetAsync(playerKey)
	end)
	
	if success3 then
		Slot3.Value = mySlot3
	else
		Slot3.Value = 1
	end
	
	Slot3.Value = slot3data:GetAsync(player.UserId) or 1
	slot3data:SetAsync(player.UserId, Slot3.Value)
	
	Slot1.Changed:Connect(function()
		slot1data:SetAsync(player.UserId, Slot1.Value)
		print("Saved "..player.Name.." Slot1")
	end)
	Slot2.Changed:Connect(function()
		slot2data:SetAsync(player.UserId, Slot2.Value)
		print("Saved "..player.Name.." Slot2")
	end)
	Slot3.Changed:Connect(function()
		slot3data:SetAsync(player.UserId, Slot3.Value)
		print("Saved "..player.Name.." Slot3")
	end)
	
	
	coroutine.resume(coroutine.create(function()
		local dataModule = require(game.ServerScriptService.data)
		while player do
			print(player.Name,"checking ban status.")
			if dataModule.LoadData(player,"ban") == true and not RunService:IsStudio() then
				local reason = dataModule.LoadData(player,"banReason") or "Unspecified reason."
				local banner = dataModule.LoadData(player,"banner") or "server"
				
				print("player is banned?")
				--player:Kick("You are banned: " .. reason .. " | You were banned by " .. banner .. " | Appeal your ban in our discord: discord.gg/ZSrURxJ")
			end
			wait(30)
		end
	end))
end)

If anyone has an idea how to fix please let me know.

2 Likes

Basically, you are setting data and getting data way too often. And it got a defined ammount of times until it throws that error.

1 Like

I wouldn’t recommend saving each time a value is changed. It is much more effective to only save when the game is either closed or the player leaves. Either way, this happens everytime data is saved with a datastore. So no need to worry.

2 Likes