DataStore Request Was Added To Que (DevProduct)

So recently I have been working a ton on scripts and datastores and I’ve been having one problem coming along it.

Datastore Request Was Added To Que

Now I have been looking at plenty and I mean plenty of scripts, and ways of going around this, but I still have no clue why its being added to queue?

  1. Could it be to many datastores?
  2. Can’t process right?
  3. Have no idea…

Here is my script and Idea ive been working on: Just a basic cash gui, and yes my local button does process the receipt and does test purchases with robux, but it gets added to que -

--[ WATCH TWINPLAYZ ON YOUTUBE FOR HELP ON THIS ]--


--[ SERVICES ]--

local MarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")

--[ LOCALS ]--

local productID = 1151442969 -- product id 1
local productID2 = 1154062158 -- product id 2

--[ FUNCTIONS ]--

local function processReceipt(receiptInfo)
	
	local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
	MarketplaceService.ProcessReceipt = processReceipt
	
	if not player then
		-- player probs left game
		-- if back then call again
		print("not processed")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	
	-- If they bought it
	if receiptInfo.ProductId == productID then
		-- checks to make sure its a player
		if player then
			player.Cash.Value = player.Cash.Value + 10 -- adds 10 cash.
			print(player.Name.. " just bought " .. receiptInfo.ProductId)
		end
		
	elseif receiptInfo.ProductId == productID2 then
			-- checks to make sure its a player
			if player then
				player.Cash.Value = player.Cash.Value + 20 -- adds 20 cash.
				print(player.Name.. " just bought " .. receiptInfo.ProductId)
		end
	end

	
	-- returns it as purchase completed.
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

And here is my Minute Leaderboard or leaderstats you can call. That normally does all the saving.

This script works perfectly fine :

--[[
	@author TwinPlayzDev_YT
	@since 1/28/2021
	This script will save and put minutes on the leaderboard. You can change minutes to anything--
	you would like just simply read the code and look at Minutes.Name = "Minutes" change "Minutes"
	to anything like "Points", "Level", etc. Please watch my youtube tutorial if needed.
--]]


--[ SERVICES ]--

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("TimeStats")
local service = game:GetService("MarketplaceService")


--[ LOCALS ]--

local VIPGamepassId = 13913938  -- VIP GAMEPASS ID
local GamepassId = 13914120  -- GAMEPASS ID


--[ FUNCTIONS ]--

game.Players.PlayerAdded:Connect(function(Player)
	

	--[{ LEADERSTATS }]--

    local Leaderstats = Instance.new("Folder")
    Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player
	
	local Minutes = Instance.new("IntValue")
	Minutes.Name = "Minutes" -- changing name here (points, levels, time, etc.)
	Minutes.Value = 0 -- default value
	Minutes.Parent = Leaderstats
	
	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash" -- changing name here (points, levels, time, etc.)
	Cash.Value = 0 -- default value
	Cash.Parent = Player
	
	
	--[{ DATA STORE }]--
	
	
	local Data = DataStore:GetAsync(Player.UserId) -- Get Data
	
	if type(Data) ~= "table" then
		Data = nil
	end
	
	if Data then
		Minutes.Value = Data.Minutes
		Cash.Value = Data.Cash
	end
	
	local incrementValue = 1 -- value when adding points

	if (service:UserOwnsGamePassAsync(Player.UserId, VIPGamepassId)) then -- 3x gamepass
		incrementValue = 3
	elseif (service:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then -- 2x gamepass
		incrementValue = 2
	end
	

	--[{ TIME GIVERS }]--
	
	
	coroutine.resume(coroutine.create(function() -- gives 1 point every minute
		while true do
			wait(60) -- every minute
			Minutes.Value = Minutes.Value + incrementValue --  adds points based off of the incrementValue
		end
	end))
	
	coroutine.resume(coroutine.create(function() -- gives 1 point every minute
		while true do
			wait(120) -- every 2 minutes
			Cash.Value = Cash.Value + incrementValue -- adds cash
		end
	end))
	
	
end)




game.Players.PlayerRemoving:Connect(function(Player) -- save function here
	
	--[{ DATA STORE SAVING }]--
	
	DataStore:SetAsync(Player.UserId, { -- gets data
		Minutes = Player.leaderstats.Minutes.Value,
		Cash = Player.Cash.Value
	})
	
end)

The Datastore request being added to queue is completely unrelated to the first script, as it doesn’t even use datastores.

1 Like

DataStores have limits. If you overwhelm it by sending numerous requests at once, it will begin to sort your requests into one of four possible queues. Each one of those queues have a 30 request limit meaning if they go past that limit, it will begin to drop requests (it will not process them as expected) and you could have issues with that. But if you get to the point where that occurs, you need to re-read your code and find out why you’re causing this issue with your requests to the datastore.

1 Like

You’re only supposed to save player data when the player leaves the game. You should check every script that impacts the datastore and see what scripts limit the datastore.

There are limits to how many requests you can send per minute. Perhaps the leaderboard sents to many requests, if so change it so it updates every 5 minutes. My only tip is to go over your scripts and see if you find something that could make the request go on max like game pass handlers etc.

1 Like

None of what you’ve shown should cause this unless you have tons of players joining/leaving at once, which I doubt is the problem.

Try performing a global search for datastore API as another script might be using datastores incorrectly.

Are you seeing this message in studio or in the live game?

3 Likes

In studio and in game. Its really weird…

Yes but im adding to the datastore by using

plr.Cash.Value = plr.Cash.Value + 10

which is always being saved in datastore.

That is your issue; if you’re constantly saving data to a datastore then you will hit the datastore limits, like Tigger said. You should only save in certain circumstances (when a player leaves, they buy a dev product, or an autosave every few minutes), don’t just constantly save or save any time that their data changes.

2 Likes

Is there any way you can tell if the values mean anything?

I looked through most of my scripts I only have saving for the following -

  1. Cash/Minutes Leaderboard
  2. GearShop Tools Save

The thing is though even before I made the gearshop tools save, it still said that It was getting added to queue…

I still don’t know how to fix.