Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ProcessReceipt function running when its not suppose to?

INSIDE A SERVER SCRIPT

This is suppose to run when a player is prompted a devproduct purchase in a local script, but it automatically just runs right when you get into the game even if you haven't bought it.

local productId = 47411842
market.ProcessReceipt = function(stuff)
	for i, player in ipairs(game.Players:GetPlayers()) do
		if player.userId == stuff.PlayerId then
			if stuff.ProductId == productId then
				events.songBought:FireClient(player)
			end
		end
	end
end

1 answer

What's happening is a bit complicated, but I think I can explain: When someone buys a developer product, ProcessReceipt(stuff) is called (durr). ROBLOX expects you to tell them, inside of the function, that you successfully processed that purchase and gave the player what they paid for. It's actually waiting for one thing in particular:

return Enum.ProductPurchaseDecision.PurchaseGranted

By including this line, you are essentially telling ROBLOX that your script didn't crash while running and the player should be happy now. However, if you don't include this, ROBLOX will assume that your script failed to give the player what they wanted, and as a result, every time the player joins the game again, it will call ProcessReceipt(stuff) again in an attempt to correct the supposed 'error' made previously. So just include the line listed above at the very end of your function and it should fix itself. I hope this helped!

1 comment

0

Also if you don't include that line, you won't get the money from the product

This discussion is preserved as it was. New answers, comments, and votes are closed.