Devproduct Script not Working

Hello! How;s everyone doing? I am trying to make my devproduct script work, but it only seems to be working on local servers (servers that are running IN studio, not in actual roblox or in team tests.) I’ve tried basically everything I can think of and I’ve traced back the problem to the function itself not firing. What am I doing wrong?

local ballDrop = 50
local mkps = game:GetService("MarketplaceService")

mkps.ProcessReceipt = function(receiptInfo) --doesnt fire AT ALL, even after I purchase the product
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        --etc etc you get the point, just normal devproduct stuff that go in scripts

No errors, no warnings. Help!!!

First, check that have actually published it with the script being commited if it is team create.

Then, ensure that that is the only time you are using ProcessReceipt. It can only be used once per game, so if you have multiple it will cause other calls of it to not function

The script has been committed, and the game has been published. I also checked to see if this was the only case of the ProcessReceipt function (it was) and the error still persists. What else can I try?

Thanks for the help btw

Are you listening to the processReceipt in another script in your game? If it hasn’t changed in the past year, you can only listen to this event in one script in your game.

I am not. I only call the function once.

1 Like

image

Show your entire script. This isn’t a good enough explanation of your code:

You should also be using Roblox’s example code:

That really isn’t needed, because the problem is that the function does not fire in the first place (SPECIFICALLY ONLY ON TEAM TESTS AND ACTUAL SERVERS)

But, I will give you the code anyways, just in case it helps.

Client-Side:

for i,v in pairs(script.Parent.Buttons:GetChildren()) do
	if v:isA("TextButton") then
		v.MouseButton1Click:connect(function()
			pcall(function()
				print("Purchase Prompted")
				game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
			end)
		end)
	end
end

Server-Side:

local function processReceipt(receiptInfo)
	print("Fired!")
	local v = true
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	print(player)
	print(receiptInfo.ProductId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	elseif player then
		if receiptInfo.ProductId == 1682197908 then
			ballDrop += 50
			game.ReplicatedStorage.notifyClients:FireAllClients(player.Name .. " just spent money to give you all 50 more balls!")
		elseif receiptInfo.ProductId == 1682198076 then
			ballDrop += 200
			game.ReplicatedStorage.notifyClients:FireAllClients(player.Name .. " just spent money to give you all 200 more balls!!!")
		elseif receiptInfo.ProductId == 1682198458 then
			ballDrop += 1000
			game.ReplicatedStorage.notifyClients:FireAllClients(player.Name .. " just spent the equvilent of $3 to give you all 1000 more balls!! Be sure to say thanks!!")
		elseif receiptInfo.ProductId == 1682199251 then
			ballDrop += 5000
			game.ReplicatedStorage.notifyClients:FireAllClients(player.Name .. " just spent 1000 robux to spawn 5K BALLS!!! MAKE IT RAIN!!!")
		else
			v = false
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		if v == true then
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
end
MarketplaceService.ProcessReceipt = processReceipt

Have you tried doing this WHILE in the local server test? (on the server)

Yes, I have purchased the product in the local server and it has worked as intended. (By local server I’m assuming you mean the Studio regular testing via the play button)

If it works in studio, what’s the problem?

It doesn’t work in actual Roblox servers or in Team Tests