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

Developer Products randomly don't work?

Asked by
soutpansa 120
4 years ago

Players are complaining that developer products take their robux and dont give them their product sometimes. Me and my friends cant figure out why

Local script in gui to prompt purchase:

local player = game.Players.LocalPlayer
local debounce = false

script.Parent["5"].MouseButton1Click:Connect(function()
    if not debounce then debounce = true
    game:GetService("MarketplaceService"):PromptProductPurchase(player, 622552409)
    script.Parent.Visible = false
    wait(5)
    debounce = false
    end
end)


script.Parent["10"].MouseButton1Click:Connect(function()
    if not debounce then debounce = true
    game:GetService("MarketplaceService"):PromptProductPurchase(player, 622553387)
    script.Parent.Visible = false
    wait(5)
    debounce = false
    end
end)


script.Parent["15"].MouseButton1Click:Connect(function()
    if not debounce then debounce = true
    game:GetService("MarketplaceService"):PromptProductPurchase(player, 622554275)
    script.Parent.Visible = false
    wait(5)
    debounce = false
    end
end)

Script in SSS to process purchases:

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


local Products = {
    [622552409] = function(receipt,player)
    --if player.Name == Name then
        local stats = player:FindFirstChild("Stats")
        local Spins = stats and stats:FindFirstChild("Spins")
        if not Spins then return end
        if Spins then player.Stats.Spins.Value = player.Stats.Spins.Value + 5 end
        return true
--      end
    end;
[622553387] = function(receipt,player)
--  if player.Name == Name then
        local stats = player:FindFirstChild("Stats")
        local Spins = stats and stats:FindFirstChild("Spins")
        if not Spins then return end
        if Spins then player.Stats.Spins.Value = player.Stats.Spins.Value + 10 end
        return true
--      end
    end;
[622554275] = function(receipt,player)
--  if player.Name == Name then
        local stats = player:FindFirstChild("Stats")
        local Spins = stats and stats:FindFirstChild("Spins")
        if not Spins then return end
        if Spins then player.Stats.Spins.Value = player.Stats.Spins.Value + 15 end
        return true
--      end
    end;





}

function MarketplaceService.ProcessReceipt(receiptInfo)
    local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
    if PurchaseHistory:GetAsync(playerProductKey) then
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end

    local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end


    local handler
    for productId,func in pairs(Products) do
        if productId == receiptInfo.ProductId then
            handler = func break
        end
    end


    if not handler then return Enum.ProductPurchaseDecision.PurchaseGranted end


    local suc,err = pcall(handler,receiptInfo,player)
    if not suc then
        warn("An error occured while processing a product purchase")
        print("\t ProductId:",receiptInfo.ProductId)
        print("\t Player:",player)
        print("\t Error message:",err)
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end


    if not err then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end


    suc,err = pcall(function()
        PurchaseHistory:SetAsync(playerProductKey, true)
    end)
    if not suc then
        print("An error occured while saving a product purchase")
        print("\t ProductId:",receiptInfo.ProductId)
        print("\t Player:",player)
        print("\t Error message:",err)
        print("\t Handler worked fine, purchase granted")
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Thanks for reading. I would appreciate any help

0
does any errors come out of the output? as your script looks fine sturdy2004 110 — 4y
0
Sometimes i get a data storage overload error, which may be causing it, but otherwise i get no errors that could be related soutpansa 120 — 4y

Answer this question