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

How to fix a developer product shop?

Asked by
Krodiix -1
4 years ago

I have two currencys in a game, the "Coins" and the "Diamonds" but theres a error that i can only buy the coins in the dev products shop, how can i fix it?

The Diamonds script: (In ServerScriptService)

local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 975623902 then -- ID Of the Diamonds product
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value + 100
        return Enum.ProductPurchaseDecision.PurchaseGranted

    elseif receiptInfo.ProductId == 975624151 then -- ID Of the Diamonds product
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value + 500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

The Leaderboard script: (In ServerScriptService)

game.Players.PlayerAdded:connect(function(plr)
    local folder = Instance.new("Folder", plr)
    folder.Name = "leaderstats"
    local value = Instance.new("IntValue", folder)
    value.Name = "Coins"
    value.Value = 10 -- starting cash
    local dia = Instance.new("IntValue", folder)
    dia.Name = "Diamonds"
    dia.Value = 5
end)

The Coins script: (In ServerScriptService)

local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 975621401 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10000
        return Enum.ProductPurchaseDecision.PurchaseGranted

    elseif receiptInfo.ProductId == 975621855 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

And a example of a buy TextButton (in a ScreenGUI in StarterGUI) LocalScript inside the button:

MPS = game:GetService("MarketplaceService")
id = 975625365 -- replace with your ID
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    MPS:PromptProductPurchase(player, id)
end)
0
So what part dosen't work FluffySheep46209 369 — 4y
0
Please provide the error. MacaylaMarvelous81 15 — 4y

Answer this question