Dev products work in studio but not in real live servers?

I’ve seen people having the same problem but I can’t seem to find a solution. My dev products work fine in studio, even the testing option in studio. But when I actually play my game, it doesn’t work. Here are the scripts.

LocalScript (player click button GUI):

local player = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")

for i, v in pairs(script.Parent:GetChildren()) do
	if v:IsA("ImageLabel") then
		if v.Name ~= "PlatPlay" then
			v.Selector.MouseButton1Click:Connect(function()
			local amt = v.Amount.Value
			local passId = v.PassID.Value
				mps:PromptProductPurchase(player, passId)
			end)
		end
	end
end

script.Parent.PlatPlay.Selector.MouseButton1Click:Connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 26865833)
end)

ServerScript:

local repstorage = game:GetService("ReplicatedStorage")
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local id1 = 1231945549
local id5 = 1231945576
local id10 = 1231945618
local id25 = 1231945649
local id75 = 1231945672

local function processReceipt(receiptInfo)
	local plr = players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not plr then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	if receiptInfo.ProductId == id1 then
		if plr then
			wait(1)
			print("id1")
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
	if receiptInfo.ProductId == id5 then
		if plr then
			wait(1)
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
	if receiptInfo.ProductId == id10 then
		if plr then
			wait(1)
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 10000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
	if receiptInfo.ProductId == id25 then
		if plr then
			wait(1)
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 25000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
	if receiptInfo.ProductId == id75 then
		if plr then
			wait(1)
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 75000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

mps.ProcessReceipt = processReceipt

Thank you!

1 Like

Nevermind! I found the solution! For anyone else that has this problem in the future, you can only processReceipt one time, you can have multiple script doing the same thing! So if you have multiple passes, you need to put them all under one processReceipt function!

3 Likes

I also recommend utilizing tables in your code rather than repeat if then statements:

local products = {
   --- '00000' is the developer product Id
   [00000] = 10000; -- this is how many coins it'll add
}

local product = products[ProductId] -- 'ProductId' would be the reference to the Receipt's ProductId

if product then
   Leaderstats.Coins.Value += product
end
1 Like