Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

So what exactly am I missing out here?

Asked by 10 years ago

I am trying to make a PlayerPoints system but the purchase prompt won't appear when the GUI button is clicked. What am I missing here?

local plr = game.Players.LocalPlayer
local productId = 19664516

script.Parent.MouseButton1Click:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(plr, productId)
    local MarketplaceService = Game:GetService("MarketplaceService")
    MarketplaceService.ProcessReceipt = function(receiptInfo)
        local PointsService = Game:GetService("PointsService")
        local pointsToAward = PointsService:GetAwardablePoints()
        local universeBalance = PointsService:GetGamePointBalance(plr.userId)

        if (pointsToAward > 0 and universeBalance == 0) then
            PointsService:AwardPoints(plr.userId, 5)
        end

        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Ah, I see you are trying to sell player points like me :P

I think the reason it isn't working is you aren't defining the ProcessReceipt function until after the purchase had been prompted. I put my whole entire ProcessReceipt function in a separate script located in ServerScriptService.

Also, you didn't define MarketplaceService. You have to do this:

local market = game:GetService("MarketplaceService")

market.ProcessReceipt = function(receiptInfo)
    --stuff
end
0
... Michael007800 144 — 10y
Ad

Answer this question