Hi guys! This completes the purchase, but does not award the coins. Any ideas? Thanks
Script in textbutton:
local MarketplaceService = game:GetService("MarketplaceService")
local productId = 22343529
-- 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.Coins.Value = player.leaderstats.Coins.Value + 100
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
localscript in textbutton:
local productId = 22343529 -- change to your developer product ID
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
