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

Why isn't this this script working?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I'm confused because i did everything the roblox wiki told me to do in this script but it still doesn't work. Can anyone tell me why? Thanks if you did!

Script:

local plr = script.Parent.Parent.Parent.Parent
local MarketplaceService = game:GetService("MarketplaceService")
local cashid = 22957008
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")


function addcash()
    if plr then
        local leaderstats = plr:FindFirstChild("leaderstats")
        if leaderstats then
            local cash = leaderstats:FindFirstChild("Cash")
            if cash then
                cash.Value = cash.Value + 10000
            end
        end
    end
end

script.Parent.MouseButton1Click:connect(function()
    MarketplaceService.ProcessReceipt = function(receiptInfo) 
        local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
        if PurchaseHistory:GetAsync(playerProductKey) then
            return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it.
        end
        -- find the player based on the PlayerId in receiptInfo
        for i, player in ipairs(game.Players:GetPlayers()) do
            if player.userId == receiptInfo.PlayerId then
                -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product)
                if receiptInfo.ProductId == cashid then
                    addcash()
                end
            end 
        end
        -- record the transaction in a Data Store
        PurchaseHistory:SetAsync(playerProductKey, true)    
        -- tell ROBLOX that we have successfully handled the transaction (required)
        return Enum.ProductPurchaseDecision.PurchaseGranted     
    end
end)
0
Please provide some information. You cannot just tell us that your script is having issues without providing us with the output or at least pointing us in the right direction. FearMeIAmLag 1161 — 9y
0
well nothing is in the output so i dodnt know 951753lolguy 2 — 9y
0
Tell us what the script is supossed to do. chill22518 145 — 9y
0
its supposed to give the player 10000 cash if the bought the developer product but this doesnt work 951753lolguy 2 — 9y

Answer this question