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

Developer Product Gui shop problem?

Asked by 9 years ago

I have a Gui shop for purchasing developer products which award "cash" on the Leaderboard. Now this script works, however it only works for one of the developer products. The one that awards 500 cash. When you pay for the other Developer products nothing happens within the leaderboard. I use the same code below for all the products, just changing the ID, and cash award values. However only the 500 cash button works. I have no idea why.

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") 

CASHID = 19990870

 MarketplaceService.ProcessReceipt = function(receiptInfo) 
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
    local numberBought = ds:IncrementAsync(playerProductKey, 1)
    for i,v in pairs (game.Players:GetChildren()) do
        if v.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == CASHID then
            lds = v:FindFirstChild("leaderstats") 
                if lds ~= nil then
                    cs = lds:FindFirstChild("Cash") 
                    if cs ~= nil then
                        cs.Value = cs.Value + 500 
                    end
                end
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
You're sending data from multiple scripts into a single DataStore. It's best to form them all into a table. TofuBytes 500 — 9y

Answer this question