How to make a new model if someone buys a developer product?

So I want to be able to use instance.New (or something else if an alternative is better) to make a model appear when you buy the developer product or gamepass. Here’s my idea:

local Player = game.Players.LocalPlayer
local MarketPlaceService = game:GetService("MarketplaceService")

local DevproductId = 000 --replace with ID
local Button = script.Parent
local modelID = 000 --replace with model id

Button.MouseButton1Click:Connect(function()
	MarketPlaceService:PromptProductPurchase(Player, DevproductId) then
	Instance.new = modelID else	
end)

And here’s the error:

Expected identifier when parsing expression, got ‘then’ - Studio - BuyScript:9

how do I fix it to make it when I buy the dev product, it spawns the model?

Look into this api MarketplaceService.ProcessReceipt

once you process the receipt make the model in the workspace

edit your script line
MarketPlaceService:PromptProductPurchase(Player, DevproductId) then

and take out the then

lmk if something else doesn’t work

local marketplace = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local productId = 0 --Change to ID of developer product.

local function processReceipt(receiptInfo)
	local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
	if player then
		if receiptInfo.ProductId == productId then
			local model = Instance.new("Model")
			model.Name = player.Name.."'s Model"
			model.Parent = workspace
		end
		
		return Enum.ProductPurchaseDecision.PurchaseGranted
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

marketplace.ProcessReceipt = processReceipt

Here’s an example script which you can make use of, it’s a server script.

For developer products you need to make use of the marketplace’s “ProcessReceipt” callback as suggested, be wary though, a game’s “ProcessReceipt” callback can only be set once. You need to handle all of a game’s developer products in a single function value assigned to the callback.

https://developer.roblox.com/en-us/api-reference/callback/MarketplaceService/ProcessReceipt

1 Like