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

How to I make 1 dev product do a something different than the other products?

Asked by
owenm00 22
3 years ago

So I am using a donation board and there is already a script inside of it looking for the product when it's bought.

Tbh I don't know what I am doing. Maybe one of u guys can help.

function ReceiptHandler()
    warn("Donation Board: ProcessReceipt Activated")
    game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
        local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
        local numberBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(playerProductKey, 1)
        local ProductBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistoryCount"):IncrementAsync(receiptInfo.ProductId, 1)
        local PlayerFound = false
    local players = game.Players:GetPlayers()

    local currency = "Stage"

        local done = 0
        for i, v in pairs (game.Players:GetChildren()) do
            if v:IsA('Player') then
                if v.userId == receiptInfo.PlayerId then
                for _, p in pairs (Products.Products) do
                    for i=1,#players do
                        if players[i].userId == receiptInfo.PlayerId then
                            if receiptInfo.ProductId == 978487374 and done == 0 then
                                done = 1
                                players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
                                players[i].TeleportedStage.Value = players[i].TeleportedStage.Value + 1
                                players[i].Character.Humanoid.Health = 0
                                done = 0
                                PlayerFound = true
                        if p.ProductId == receiptInfo.ProductId then
                            if v ~= nil then
                                PlayerFound = true
                                game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago

Probably something like this:

if players[i].userId == receiptInfo.PlayerId then
                            if receiptInfo.ProductId == 978487374 and done == 0 then
                                done = 1
                                players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
                                players[i].TeleportedStage.Value = players[i].TeleportedStage.Value + 1
                                players[i].Character.Humanoid.Health = 0
                                done = 0
                                PlayerFound = true
                        if p.ProductId == receiptInfo.ProductId then
                            if v ~= nil then
                                PlayerFound = true
                                game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
                                end
                            end
                        end

you copy paste this under this exact script and you change the Developer Product Id 978487374 and then in the lines below that you change what ever u want the developer product to do for example u can change Humanoid Speed,Health,JumpPower and more

Ad

Answer this question