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

Dev products failing to be bought?

Asked by
Prioxis 673 Moderation Voter
9 years ago

So I'm playing my game and when I go to buy dev products it says "failed to be bought account not charged" and when I went on an alt and tried buying it, it gave me the same error

heres my devproduct script in serverscriptservice

game.StarterGui.ResetPlayerGuiOnSpawn = false

local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
    for i,v in pairs(game.Players:GetChildren()) do
        if v.userId == id then
            return v
        end
    end
    return nil
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local playerId = receiptInfo.PlayerId
    local player = getPlayerFromId(playerId)
    local productName 
    if productId == 30310757 then
        productName = "$2,000"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 2000
        end
    elseif productId == 30310791 then
        productName = "$10,000!"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
    elseif productId == 30310772 then
        productName = "+5 Walkspeed"
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.WalkSpeed = human.WalkSpeed + 5
            end
        end
    elseif productId == 30310800 then
        productName = "Gravity Coil"
        game.Lighting.GravityCoil:Clone().Parent=player.Backpack
    end

    local message = Instance.new("Hint",workspace)
    message.Text = player.Name.." purchased "..productName.."!"
    coroutine.resume(coroutine.create(function()
        wait(2)
        message:destroy()
    end))

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

here's the button scripts

for i,v in pairs(script.Parent.Buttons:GetChildren()) do
    if v:isA("TextButton") then
        v.MouseButton1Click:connect(function()
            pcall(function()
                if v:FindFirstChild("Pass") then
                    game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                else    
                    game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                end
            end)
        end)
    end
end

1 answer

Log in to vote
0
Answered by
Prioxis 673 Moderation Voter
9 years ago

Turns out thirdpartysales a variable in the workspace object has to be enabled for some odd reason?!

Ad

Answer this question