Dev products are not going through

Hello developers, I am currently working on a game and all of a sudden the dev product handler script no longer functions. It was working before but i am unsure why it isnt working anymore. When i purchase the product in studio, it works fine. But if i tried it in-game. It does not do anything. It puts a message in the developer console when i test it ingame saying: (DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests)

If anyone could help me with the fix since it was working before and now it isnt, It would be highly appreciated!

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

local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")

local productFunctions = {}

productFunctions[product1] = function(receipt, player)
	(typical product info here)
	return true
end

productFunctions[product2] = function(receipt, player)
	(typical product info here)
	return true
end

productFunctions[product3] = function(receipt, player)
	(typical product info here)
	return true
end

productFunctions[product4] = function(receipt, player)
	(typical product info here)
	return true
end

productFunctions[product5] = function(receipt, player)
	(typical product info here)
	return true
end

productFunctions[product6] = function(receipt, player)
	(typical product info here)
	return true
end

local function processReceipt(receiptInfo)

	local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId

	local success, isPurchaseRecorded = pcall(function()
		return purchaseHistoryStore:UpdateAsync(playerProductKey, function(alreadyPurchased)
			if alreadyPurchased then
				return true
			end

			local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
			if not player then
				return nil
			end

			local handler = productFunctions[receiptInfo.ProductId]

			local success, result = pcall(handler, receiptInfo, player)
			if not success or not result then
				error("Failed to process a product purchase for ProductId:", receiptInfo.ProductId, " Player:", player)
				return nil
			end
			return true
		end)
	end)

	if not success then
		error("Failed to process receipt due to data store error.")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	elseif isPurchaseRecorded == nil then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else	
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

MarketplaceService.ProcessReceipt = processReceipt
1 Like

It means you’re sending too many DataStore requests at a time.

Are there any other DataStores you’re using in your game besides the one in the script provided above?

Yes, im using one that saves a players data whenever the value “coins” changes inside the player. The value doesnt change often though since coins are only obtainable by finding a few boxes around the map and buying them.

Can I see the script for that? I just want to check and see if the issue is there.

Alright this is the whole script for saving the players data.

local datastoreservice = game:GetService("DataStoreService")

local datastore = datastoreservice:GetDataStore("Datastore")

MPS = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Value = 0
	Coins.Parent = player
	
	local success,errorMsg = pcall(function()
		data = datastore:GetAsync(player.UserId)
	end)
	
	wait(0.5)
	
	if data ~= nil then
		if data.Coins then
			player.Coins.Value = data.Coins
		end
	end
end)

wait(2)

for i, player in pairs(game.Players:GetPlayers()) do
	player.Coins.Changed:Connect(function()
		local data = {}

		data.Coins = player.Coins.Value

		local success,errorMsg = pcall(function()
			datastore:SetAsync(player.UserId,data)
		end)

		if success then
			print("Success")
		end

		if errorMsg then
			print("Error found while trying to save data (are roblox datastore servers down?)"..errorMsg)
		end
	end)
end

game:BindToClose(function()

	for i, player in pairs(game.Players:GetPlayers()) do
		local data = {}
		
		data.Coins = player.Coins.Value
		
		local success,errorMsg = pcall(function()
			datastore:SetAsync(player.UserId,data)
		end)
		
		if success then
			print("Success")
		end
		
		if errorMsg then
			print("Error found while trying to save data (are roblox datastore servers down?)"..errorMsg)
		end
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	local data = {}
	
	data.Coins = player.Coins.Value
	
	local success,errorMsg = pcall(function()
		datastore:SetAsync(player.UserId,data)
	end)
	
	if success then
		print("Success")
	end
	
	if errorMsg then
		print("Error found while trying to save data (are roblox datastore servers down?)"..errorMsg)
	end
end)

I see the issue.

To clarify, the script that saves the player’s data works right? It’s been saving the data correctly?