so i have this script in replicaced storage as a module script:
return {
Cash50 = 1234567890, -- <-- replace with your dev product id
Cash100 = 1234567891,
Cash200 = 1234567892,
Cash350 = 1234567893,
Cash500 = 1234567894,
Cash750 = 1234567895,
Cash1000 = 1234567896,
Cash2000 = 1234567897,
Cash5000 = 1234567898,
}
and then in side of each buybutton local script, or function
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local PRODUCT_ID = 1234567890 ----- whatever the product ID is for the button
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(player, PRODUCT_ID)
end)
but theres one script left which i dont know where to put:
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local PRODUCT_TO_CASH = {
[1234567890] = 50,
[1234567891] = 100,
[1234567892] = 200,
[1234567893] = 350,
[1234567894] = 500,
[1234567895] = 750,
[1234567896] = 1000,
[1234567897] = 2000,
[1234567898] = 5000,
}
local function grantCash(player, amount)
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats then return false end
local cash = leaderstats:FindFirstChild("Cash")
if not cash then return false end
cash.Value += amount
return true
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local cashAmount = PRODUCT_TO_CASH[receiptInfo.ProductId]
if not cashAmount then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local ok = grantCash(player, cashAmount)
if not ok then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end