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

How do I make sure this works all the time?

Asked by
ItsMeKlc 235 Moderation Voter
9 years ago

Ok so this is the script I made for purchasing currency, and apparently people sometimes aren't getting their currency... Anyway to fix this? I'm really stuck...

local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
    --game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId
    if receiptInfo.ProductId == 25740543 then--1000
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].userId == receiptInfo.PlayerId  then
            players[i].leaderstats["Tokens"].Value = players[i].leaderstats["Tokens"].Value + 1000
            local gui = game.ServerStorage.assets.EXTRAINFO:Clone()
            gui.TextLabel.Text = (players[i].Name.." just bought $1,000 Tokens")
            gui.Parent = game.Workspace.game.Gui            
            break
        end
    end
    elseif receiptInfo.ProductId == 25740553 then--7500 
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].userId == receiptInfo.PlayerId  then
            players[i].leaderstats["Tokens"].Value = players[i].leaderstats["Tokens"].Value + 7500
            local gui = game.ServerStorage.assets.EXTRAINFO:Clone()
            gui.TextLabel.Text = (players[i].Name.." just bought $7,500 Tokens")
            gui.Parent = game.Workspace.game.Gui            
            break
        end
    end 

    elseif receiptInfo.ProductId == 25740591 then--20,000 
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].userId == receiptInfo.PlayerId  then
            players[i].leaderstats["Tokens"].Value = players[i].leaderstats["Tokens"].Value + 20000
            local gui = game.ServerStorage.assets.EXTRAINFO:Clone()
            gui.TextLabel.Text = (players[i].Name.." just bought $20,000 Tokens")
            gui.Parent = game.Workspace.game.Gui            
            break
        end
    end 
    elseif receiptInfo.ProductId == 25740608 then -- 1,000,000
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].userId == receiptInfo.PlayerId  then
            players[i].leaderstats["Tokens"].Value = players[i].leaderstats["Tokens"].Value + 1000000
            local gui = game.ServerStorage.assets.EXTRAINFO:Clone()
            gui.TextLabel.Text = (players[i].Name.." just bought $1,000,000 Tokens")
            gui.Parent = game.Workspace.game.Gui            
            break
        end
    end     




    end
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end


Answer this question