I have used the correct scripts that are in the wiki to get some developer products working that gives the user in-game cash. I have multiple versions of these scripts, as I want a 100 cash, 500 cash and 1000 cash available purchase. However, when I go to test, only one of these buttons ever work. Any idea why?

Server side code:

local MarketplaceService100 = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local devproductId100 = 108134086 -- 100 cash
MarketplaceService100.ProcessReceipt = function(receiptInfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == devproductId100 then
				player.leaderstats.Caps.Value = player.leaderstats.Caps.Value + 100
				print("100 caps")
			end
		end
	end
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
	ds:IncrementAsync(playerProductKey, 1)		
	return Enum.ProductPurchaseDecision.PurchaseGranted

end

Local side code:

local button = script.Parent
local devproductId100 = 108134086

button.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, devproductId100)
end)

The same is for each developer prdocut, apart from the numbers after the variables 'MarketplaceService' and 'devproductId' are different, depending on the amount of cash given.

3 comments

0

Post the code

0

Done.

0

you only have one developer product ID check, of course only one is going to work. Use an elseif statement