I made a market place service script that works just fine during test mode. The script gives a Gachapon that when opened, will give a random item. It works perfectly on test mode, but when I open it in the normal game it says that the purchase has failed and something went wrong. Here is the script, and the other script that goes along with it inside of the button:
local productId = 45579253
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
local MarketplaceService = game:GetService("MarketplaceService")
local LowID, MedID = 45579253, 20754348
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local boo = game.Players.LocalPlayer
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
if PurchaseHistory:GetAsync(playerProductKey) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for i, player in ipairs(game.Players:GetPlayers()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == LowID then
local o =game.Lighting.Gachapons.ChristmasGachapon:Clone()
o.Parent = boo.Backpack
elseif receiptInfo.ProductId == MedID then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500000 -- I don't use the MedID, but I keep it there incase I will ever put another item in to buy
end
end
end
PurchaseHistory:SetAsync(playerProductKey, true)
return Enum.ProductPurchaseDecision.PurchaseGranted
end

3 comments
It would be nice if you would put your script into a code block so it is easier to read. :)
I did but it didn't show up like it should of ;-; I'll try again
There we go. The first 5 lines is the script that is in the GUIButton, and the second handles the purchases. Sorry about that