local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ProductToQuantity = {
[3296774010] = 25000,
[3296774101] = 100000,
[3296774225] = 250000,
}
local purchaseEvent = ReplicatedStorage:WaitForChild("PurchaseEvent")
-- Handle the remote event fired from the client to prompt purchase
purchaseEvent.OnServerEvent:Connect(function(player, productId)
if typeof(productId) == "number" then
MarketplaceService:PromptProductPurchase(player, productId)
end
end)
-- Process the purchase receipt and award the correct amount of money
local function processReceipt(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
-- Player not found, defer processing
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local productId = receiptInfo.ProductId
local quantity = ProductToQuantity[productId]
if quantity then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local moneyStat = leaderstats:FindFirstChild("Money")
if moneyStat then
moneyStat.Value = moneyStat.Value + quantity
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
why does this only work 1 time and after i rejoin nothing happens???
i have been stuck with this for day and i have no clue how to fix this