So I have fully made script and GUI for cash shop. Everything seems to work pretty well in roblox studio. However, when i join in actual game i am getting this error:
–Datastore request was added to queue. if request queue fills, further request will be dropper. try sending fewer requests.key = 1233892301
before i go any further i want to tell that i am also using saving system.
Here is full script:
local MarketplaceService = game:GetService(“MarketplaceService”)
local DataStoreService = game:GetService(“DataStoreService”)
local Players = game:GetService(“Players”)
local serverStorage = game:GetService(“ServerStorage”)
– Data store for tracking purchases that were successfully processed
local purchaseHistoryStore = DataStoreService:GetDataStore(“PurchaseHistory”)
local productFunctions = {}
– ProductId 456456 for 1000 CASH
productFunctions[1233755152] = function(receipt, player)
local playerMoney = serverStorage:WaitForChild("PlayerMoney")
local plrCash = playerMoney:FindFirstChild(player.Name)
if plrCash then
plrCash.Value = plrCash.Value + 1000
return true
end
end
– ProductId 456456 for INF CASH
productFunctions[1233848887] = function(receipt, player)
local playerMoney = serverStorage:WaitForChild("PlayerMoney")
local plrCash = playerMoney:FindFirstChild(player.Name)
if plrCash then
plrCash.Value = plrCash.Value + math.huge
return true
end
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt