Dev Products not working when there are more than 1 players in a server

Hi! Im making a new game and i made some developer products, when i test them in roblox studio and test in game when im the only one there it works, but when there are players in the server it starts to not work?

Could you show us the code?

Here:

local products = {

Trophy5 = {
	id = 1387569055,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 5
	end,
},

Trophy20 = {
	id = 1387569112,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 20
	end,
},

Trophy50 = {
	id = 1387569223,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 50
	end,
},

Trophy100 = {
	id = 1387569412,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 100
	end,
},

Trophy200 = {
	id = 1387569455,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 200
	end,
},

Trophy500 = {
	id = 1387569517,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 500
	end,
},

Trophy1K = {
	id = 1387569594,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 1000
	end,
},

Trophy2K = {
	id = 1387569645,
	func = function(plr)
		plr.leaderstats["🏆Trophy"].Value += 2000
	end,
},

}

local MarketPlaceService = game:GetService(“MarketplaceService”)

function MarketPlaceService.ProcessReceipt(receipt)
local devProductId = receipt.ProductId
local plr = game.Players:GetPlayerByUserId(receipt.PlayerId)
for i, product in pairs(products) do
if product.id == devProductId then
local succ, err = pcall(function()
product.func(plr)
end)

	end
end
return Enum.ProductPurchaseDecision.PurchaseGranted

end

NOTE: im not getting any errors

function -- why?? 

MarketPlaceService.ProcessReceipt(receipt)
local devProductId = receipt.ProductId
local plr = game.Players:GetPlayerByUserId(receipt.PlayerId)
for i, product in pairs(products) do
if product.id == devProductId then
local succ, err = pcall(function()
product.func(plr)
end)

Updated code

MarketPlaceService.ProcessReceipt = function(receipt)
local devProductId = receipt.ProductId
local plr = game.Players:GetPlayerByUserId(receipt.PlayerId)
for i, product in pairs(products) do
if product.id == devProductId then
local succ, err = pcall(function()
product.func(plr)
end)

Remember ProcessReceipt is a callback, it isn’t a function. This is the big mistake.

1 Like

Its still not working when i actually play in the game but it works in roblox studio, i dont get any errors tho either

1 Like

Here is the LocalScript i use for the Text Buttons that prompt the dev product, you can check if there is any problem here

productId = 1387569055

local mkp = game:GetService(“MarketplaceService”)

script.Parent.MouseButton1Click:Connect(function()

mkp:PromptProductPurchase(game.Players.LocalPlayer,productId)

end)

Nvm i found the fix!. If anyone also has a similar problem, it’s probably because you have more than one script for Developer Products! Make sure you only have one server script that processes reciepts

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