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
5 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)

01local MPS = game:GetService("MarketplaceService")
02 
03MPS.ProcessReceipt = function(receiptInfo)
04    if receiptInfo.ProductId == 975623902 then -- ID Of the Diamonds product
05        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
06        player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value + 100
07        return Enum.ProductPurchaseDecision.PurchaseGranted
08 
09    elseif receiptInfo.ProductId == 975624151 then -- ID Of the Diamonds product
10        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
11        player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value + 500
12        return Enum.ProductPurchaseDecision.PurchaseGranted
13    end
14end

The Leaderboard script: (In ServerScriptService)

01game.Players.PlayerAdded:connect(function(plr)
02    local folder = Instance.new("Folder", plr)
03    folder.Name = "leaderstats"
04    local value = Instance.new("IntValue", folder)
05    value.Name = "Coins"
06    value.Value = 10 -- starting cash
07    local dia = Instance.new("IntValue", folder)
08    dia.Name = "Diamonds"
09    dia.Value = 5
10end)

The Coins script: (In ServerScriptService)

01local MPS = game:GetService("MarketplaceService")
02 
03MPS.ProcessReceipt = function(receiptInfo)
04    if receiptInfo.ProductId == 975621401 then -- replace with your ID here
05        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
06        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10000
07        return Enum.ProductPurchaseDecision.PurchaseGranted
08 
09    elseif receiptInfo.ProductId == 975621855 then -- replace with your ID here
10        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
11        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50000
12        return Enum.ProductPurchaseDecision.PurchaseGranted
13    end
14end

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

1MPS = game:GetService("MarketplaceService")
2id = 975625365 -- replace with your ID
3local player = game.Players.LocalPlayer
4 
5script.Parent.MouseButton1Click:connect(function()
6    MPS:PromptProductPurchase(player, id)
7end)
0
So what part dosen't work FluffySheep46209 369 — 5y
0
Please provide the error. MacaylaMarvelous81 15 — 5y

Answer this question