Donation leaderboard not updating! Help Please!

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!)
--]]

Im sorry, but i don’t not quite understand your problem. Are you trying to display donations on a donation leader board?

The leaderboard updates the amount the player donates. But after I updated the badge script to give a badge after 100 robin is donated. The donation board stop updating. When I disable the badge script, the donation board will update the donation amounts.

Hello, I do not have a chance to test It out, so It might not work but I think that you need to integrate the receipt processing for both in a single ProcessReceipt function. This function should be able to distinguish between different product purchases and take the appropriate action for each (updating the donation board or awarding a badge).

local MarketplaceService = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")

local badgeProductId = 1792718870
local badgeId = 273973985081904

local products = {
    [1792712917] = function(player)
    end,
    [1792713903] = function(player)
    end,
    [1792714392] = function(player) 
    end,
    [badgeProductId] = function(player)
        if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId) then
            BadgeService:AwardBadge(player.UserId, badgeId)
            print(player.Name .. " received the Contributor badge!")
        else
            warn(player.Name .. " already has the Contributor badge.")
        end
    end,
    -- Add more products bla bla...
}

local function processReceipt(receiptInfo)
    local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if player then
        local handler = products[receiptInfo.ProductId]
        if handler then
            handler(player)
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
    end
    return Enum.ProductPurchaseDecision.NotProcessedYet
end

MarketplaceService.ProcessReceipt = processReceipt

1 Like

if I enable the “module.AbortCustomPurchases = true” in the donation board module script. The donation purchase will give me a badge. But the donation board will not update the players robux donated.

If I disable the “module.AbortCustomPurchases = true” in the donation board script. The donation board will update the players donated robux amount. But I will not receive the donation badge.

So I guess I must choose which is more important, the donation leaderboard or the donation badge.