So I am using a donation board and there is already a script inside of it looking for the product when it's bought.
Tbh I don't know what I am doing. Maybe one of u guys can help.
function ReceiptHandler()
warn("Donation Board: ProcessReceipt Activated")
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
local numberBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(playerProductKey, 1)
local ProductBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistoryCount"):IncrementAsync(receiptInfo.ProductId, 1)
local PlayerFound = false
local players = game.Players:GetPlayers()
local currency = "Stage"
local done = 0
for i, v in pairs (game.Players:GetChildren()) do
if v:IsA('Player') then
if v.userId == receiptInfo.PlayerId then
for _, p in pairs (Products.Products) do
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 978487374 and done == 0 then
done = 1
players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
players[i].TeleportedStage.Value = players[i].TeleportedStage.Value + 1
players[i].Character.Humanoid.Health = 0
done = 0
PlayerFound = true
if p.ProductId == receiptInfo.ProductId then
if v ~= nil then
PlayerFound = true
game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
end
end
end
end
end
end
end
end
end
