Gear DevProduct not working sometimes

I have some dev products in my game, on purchasing you should get the gear but it seems to not work sometimes. It shows the purchase succeded but doesn’t actually give the gear.

DevProduct Script (ServerScriptService):

local mpService = game:getService("MarketplaceService")

wait(5)
mpService.ProcessReceipt = function(purchaseInfo)
local plr = game:getService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)

if purchaseInfo.ProductId == 460093218  then -- first product id
    game.ServerStorage.GreenBalloon :Clone().Parent = plr.Backpack -- give the item to them

elseif purchaseInfo.ProductId == 454518973 then -- second product id
    game.ServerStorage.FlyingCarpet :Clone().Parent =  plr.Backpack

elseif purchaseInfo.ProductId == 454518001 then -- third product id
    game.ServerStorage.GravityCoil :Clone().Parent =  plr.Backpack

end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

Gear Button Script:

local productId = 454518001 -- Change to the ID of your developer product.

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)

end)

It’d be great if someone could help me out to fix this.

Have you verified that there are no errors in the console output? I would expect none of the purchases to work due to a syntax error as such:

GravityCoil :Clone()

There should not be a space before :Clone(), make sure to remove the space on all three lines that have this issue in your code snippet.

Besides this, nothing else jumps out at me as to why this wouldn’t work.

As a side note, I would recommend reading some of the best practices for product purchases listed on this page, including only returning PurchaseGranted when it completes successfully, returning NotProcessedYet for some edge cases (or if no handler is found for the product ID), and keeping a record of the purchase somewhere.

2 Likes

Yeah it seems fixed now. Thanks for helping me out.