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

How do I add player points to my game when a developer product is purchased?

Asked by 10 years ago

I need to know how to make the player point balance in my game add 100 when a developer product is purchased, this is what I have:

productId = 20619401

local MarketplaceService = Game:GetService("MarketplaceService")
function UsernameFromID(ID)
    if type(ID) ~= "number" then
    return
    end
    local sets = game:service("InsertService"):GetUserSets(ID)
    for k, v in next, sets do
        if v.Name == "My Models" then
            return v.CreatorName
        end
    end
end
function giveRewards(player)
    points = Game:GetService("PointsService")
    player.Character:PromptPurchase(20619401) -- HELP NEEDED HERE
    return Enum.ProductPurcaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
    giveRewards(UsernameFromID(receiptInfo.PlayerId))
end
script.Parent.MouseButton1Down:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId)
end)

Answer this question