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

How to use Developer Products properly?

When me and my friends tested the Developer Products it says the product is not for sale

local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent.TextButton
local productId = 000000000 -- I didn't show the real productId
 
buyButton.MouseButton1Click:connect(function()
	MarketplaceService:PromptProductPurchase(player, productId)
end)

I also tried to make a Developer Product that increases your money value by 2000

--Script in Starter Pack

local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local productId = 20518668
 
-- when player clicks on buy brick prompt him/her to buy a product
buyButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
 
 
--Script in button

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 20518668
 
-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 
 
	-- find the player based on the PlayerId in receiptInfo
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
 
 
			-- check which product was purchased
			if receiptInfo.ProductId == productId then
 
				-- handle purchase
				player.leaderstats.Money.Value = player.leaderstats.Money.Value + 2000
			end
		end
	end	
 
	-- record the transaction in a Data Store
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
	ds:IncrementAsync(playerProductKey, 1)	
 
	-- tell ROBLOX that we have successfully handled the transaction
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

1 answer

You might of gotten a error from line 8 as the variable is described as productId but it is catching it as LproductId.

Is the script in the starterpack a local Script? If not, it would error due to it being a normal script and you may need to change it to a local Script. Those appear to be the only two things wrong that may need to be done to have it work.

2 comments

0

I see it says LproductId

0

I will try it

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