My donation board is not updating the donation amounts after I purchase a donation. The donation board was updating until I added a contributor badge script to give a badge after a certain donation is purchased. I including the donation board script as well as the contributor badge script. The donation board script in not my script. Can someone point me in the right direction that will allow the donation board to update after a donation purchase? thanks!
--contributor badge script
local MarketplaceService = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")
local ProductId = 1792718870 -- Replace with your actual product ID
local BadgeId = 273973985081904 -- Replace with your badge ID
local function warn(message)
print("WARNING: " .. message)
end
local function processReceipt(receiptInfo, player)
print("Processing receipt for player: " .. player.Name)
if receiptInfo.ProductId == ProductId then
print("Received receipt for product ID: " .. receiptInfo.ProductId)
-- Check if the player already has the badge
if not BadgeService:UserHasBadgeAsync(player.UserId, BadgeId) then
print("Awarding badge to player: " .. player.Name)
-- Award the badge
BadgeService:AwardBadge(player.UserId, BadgeId)
print(player.Name .. " received the Contributor badge!")
else
warn(player.Name .. " already has the Contributor badge.")
end
end
end
local function onPlayerAdded(player)
print("Player added: " .. player.Name)
-- Prompt the product purchase
print("Prompting product purchase for player: " .. player.Name)
MarketplaceService:PromptProductPurchase(player, ProductId)
-- Connect the receipt processing function
print("Connecting receipt processing function for player: " .. player.Name)
MarketplaceService.ProcessReceipt = function(receiptInfo)
processReceipt(receiptInfo, player)
end
end
game.Players.PlayerAdded:Connect(onPlayerAdded)
-- donation board script
local module = {}
module.Products = {
{
ProductPrice = 5, --The price from the Developer Product.
ProductId = 1792712917 -- The ID from the Developer Product.
},
{
ProductPrice = 10, --The price from the Developer Product.
ProductId = 1792713903 -- The ID from the Developer Product.
},
{
ProductPrice = 50, --The price from the Developer Product.
ProductId = 1792714392 -- The ID from the Developer Product.
},
{
ProductPrice = 100, --The price from the Developer Product.
ProductId = 1792718870 -- The ID from the Developer Product.
},
}
--module.AbortCustomPurchases = true --READ Below for what this does.
return module
--[[
to make more products just copy and past like this:
module.Products = {
{
ProductPrice = 0, --The price from the Developer Product.
ProductId = 0 -- The ID from the Developer Product.
},
{
ProductPrice = 0, --The price from the Developer Product.
ProductId = 0 -- The ID from the Developer Product.
},
{
ProductPrice = 0, --The price from the Developer Product.
ProductId = 0 -- The ID from the Developer Product.
},
}
For the more advanced scripters, READ THIS!
if you're already using the function ProcessReceipt then you must add custom code for this board to work,
as only one of these functions may be used in a game.
to disable the ProcessReceipt function from this board, unquote this above the 'return module' line:
module.AbortCustomPurchases = true
you can update the boards datastore with this line:
game:GetService("DataStoreService"):GetOrderedDataStore("TopDonators"):IncrementAsync(PlayerId, ProductPrice)
-PlayerId, the id from the player who bought the pruduct.
-ProductPrice, the developer products price (In Rs!)
--]]