Problem with Developer Products - Problemi con i Developer Products

EN:

Hello developers! I am a developer of a game on Roblox but we have a big problem. When people buy money from the shops, the script of the recepit dont give them money. This is weird because when I try this on Studio, everything works. Someone know what’s the problem? These are the scripts:

Shop Buttons Script:

local MarketplaceService = game:GetService("MarketplaceService")
local productId = script.Parent.Parent.ProductID.Value  -- Change this to your developer product ID
-- Function to prompt purchase of the developer product
script.Parent.MouseButton1Click:Connect(function()
	MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

Script in ServerScriptService:

local ProductToQuantity = {
	[1831844703] = 10000000,
	[1831845742] = 1000000000,
	[1831844892] = 50000000,
	[1831845035] = 100000000,
	-- Add more product IDs and quantities as needed
}

game.Players.PlayerAdded:Connect(function(player)
	local Leaderstats = player:WaitForChild("leaderstats")

	local function processReceipt(receiptInfo)
		local productId = receiptInfo.ProductId
		local quantity = ProductToQuantity[productId]

		if quantity then
			local Leaderstat = Leaderstats:FindFirstChild("Money") -- Change Coins to whatever your currency is
			Leaderstat.Value = Leaderstat.Value + quantity
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	game:GetService("MarketplaceService").ProcessReceipt = processReceipt
end)

ITA:

Ciao a tutti developers! Sono un developer di un gioco su Roblox ma abbiamo un grande problema. Quando le persone comprano dei soldi dal negozio tramite dei developer products lo script della “ricevuta” (recepit) non da i soldi ai giocatori. Questo è molto strano perché facendo vari test da Studio tutto funziona perfettamente. Qualcuno potrebbe aiutarmi? Gli script sono questi qui sopra. Grazie!

1 Like

If it works in studio and not in game, you have maybe forgot to publish the place to roblox

1 Like

Of course I did. But that’s not the problem…

You should be changing the ProcessReceipt callback only once during an experience, not when every player is joining. If this is working in Studio (when only one player is joining, therefore you are changing it only once during an experience, which is intended) this may be why, vice changing it multiple times. I’m not familiar enough with changing the callback multiple times, but this may be causing your issue, because there aren’t any checks otherwise that would be blocking it.

if quantity then
	local Leaderstat = Leaderstats:FindFirstChild("Money") -- Change Coins to whatever your currency is
	Leaderstat.Value = Leaderstat.Value + quantity
end

Additionally, you should be doing something with this check. As is, if players purchase a developer product that has been incorrectly configured, they will be charged for the purchase with nothing being awarded to them. Highly recommended returning Enum.ProductPurchaseDecision.NotProcessedYet if quantity == nil, that way when you fix it and the player joins again, they will be awarded their currency.

Thank you so much! I didn’t knew that was that the problem!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.