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

Can someone help me?

Asked by 8 years ago

The cash works fine but when it needs gives gear it doesn't work. What is wrong?

            elseif receiptInfo.ProductId == GearEen then
                game.Lighting.GravityCoil:Clone().Parent=player.Backpack
            end

^^^^^^ I think the problem is here..

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local thousandCash = 23194788 --Put the ID for the thousand cash buy
local five_hundredCash = 23194787 --ID for 500 cash buy
local five_thousandCash = 23216025 --ID for 500 cash buy
local GearEen = 25553578 --ID for Gear

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 == five_hundredCash then
                local stat = v.leaderstats:FindFirstChild("Cash")
                if stat ~= nil then
                    stat.Value = stat.Value + 500
                end
            elseif receiptInfo.ProductId == thousandCash then
                local stat = v.leaderstats:FindFirstChild("EggsCandy")
                if stat ~= nil then
                    while true do
                        stat.Value = stat.Value + 550
                        wait (5)
                    end
                end
            elseif receiptInfo.ProductId == five_thousandCash then
                local stat = v.leaderstats:FindFirstChild("EggsCandy")
                if stat ~= nil then
                    stat.Value = stat.Value + 500
                end
            elseif receiptInfo.ProductId == GearEen then
                game.Lighting.GravityCoil:Clone().Parent=player.Backpack
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Answer this question