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

So what exactly am I missing out here?

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

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

1 comment

0

...

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