I've been having some trouble with this over time. My problem is that someone could press Cancel (On the GUI Prompt to purchase the Developer Product) and 5 minutes later, they'd get the product. On other occasions, people would properly purchase the Developer Product, but they wouldn't receive an item. They would need to purchase it again. If I test the script in a server by myself, it would appear to work without any flaws. Does anybody have any pointers? Any help in advance is appreciated.
local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 21341246 game.Players.PlayerAdded:connect(function() print("start") local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage() for _, DevProductContainer in pairs(DeveloperProducts) do for Field, Value in pairs(DevProductContainer) do print(Field .. ": " .. Value) end print(" ") end print("end") end) MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == productId then for i,v in pairs(player.Order:GetChildren()) do if v:IsA("BoolValue") then game.Lighting[v.Name]:clone().Parent = player.Backpack end end player.Order:ClearAllChildren() player.Order.Value = false end end end local playerProductKey = "p_" .. receiptInfo.PlayerId .. "_p_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
is it a local script?