I tried making a Buy coins UI script but it does not work
It takes the robux but it does not add the money.
Script inside the text button:
local mps = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local id = 1236310652
script.Parent.MouseButton1Click:Connect(function()
mps:PromptProductPurchase(player, id)
end)
The script inside serverscriptservice:
local mps = game:GetService("MarketplaceService")
local id = 1236309956
local id2 =1236310540
local id3 = 1236310652
local function processReciept(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
if receiptInfo.ProductId == id then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
end
if receiptInfo.ProductId == id2 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 100
end
if receiptInfo.ProductId == id3 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
I tried for 5 days to make this work but it does not seem to
Leaderstats value:
local mps = game:GetService("MarketplaceService")
local id = 1236309956
local id2 =1236310540
local id3 = 1236310652
local function processReciept(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
if receiptInfo.ProductId == id then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
end
if receiptInfo.ProductId == id2 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 100
end
if receiptInfo.ProductId == id3 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = processReciept
Yes, it is. I would like to simplify some things though, just to make it easier to modify. I suggest using this one
local mps = game:GetService("MarketplaceService")
local id = 1236309956
local id2 =1236310540
local id3 = 1236310652
local function processReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then local coins = player.leaderstats.Coins
if receiptInfo.ProductId == id then
coins.Value += 10
end
if receiptInfo.ProductId == id2 then
coins.Value += 100
end
if receiptInfo.ProductId == id3 then
coins.Value += 1000
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = processReceipt
OMG! Thank you so much for helping me. I really wanted fast help as this was for a commission. Thank you so much!!!. You to sure and definitely have a good day/night
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local coinProducts = {[1236309956] = 10, [1236310540] = 100, [1236310652] = 1000}
local function processReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
if coinProducts[receiptInfo.ProductId] then
player.leaderstats.Coins.Value += coinProducts[receiptInfo.ProductId]
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = processReceipt