Hello, I have a Donation Leaderboard, I have a problem that I can’t fix, when someone donates for the leaderboard they don’t get updated on the leaderboard, it worked before when it was first made and it just stopped working for some reason, I did get saved in the data store and I load up on the leaderboard but whenever I buy a developer product the numbers stay the same even after the leaderboard refresh, it just doesn’t update for some reason and I can’t fix it, API Services are enabled in game settings, any help would be appreciated, here is the part of the script for the leaderboard:
local function refreshLeaderboard()
-- Clear all frames except Sample
for _, child in ipairs(PlayerHolder:GetChildren()) do
if child:IsA("Frame") and child.Name ~= "Sample" then
child:Destroy()
end
end
local success, data = pcall(function()
return DonationsDS:GetSortedAsync(false, 10):GetCurrentPage()
end)
if not success then
warn("Failed to get leaderboard data")
return
end
for rank, entry in ipairs(data) do
local userId = tonumber(entry.key)
local donated = entry.value
local username = "Unknown"
local displayName = "Unknown"
local thumbUrl = ""
pcall(function()
username = Players:GetNameFromUserIdAsync(userId)
end)
pcall(function()
displayName = username -- Roblox does not have GetUserNameFromUserIdAsync, so fallback
end)
pcall(function()
thumbUrl = "https://www.roblox.com/headshot-thumbnail/image?userId="..userId.."&width=48&height=48&format=png"
end)
local newFrame = Sample:Clone()
newFrame.Name = "Player_" .. userId
newFrame.Visible = true
newFrame.Parent = PlayerHolder
local profilePic = newFrame:FindFirstChild("ProfilePicture")
local displayNameLabel = newFrame:FindFirstChild("DisplayName")
local nameLabel = newFrame:FindFirstChild("Name")
local donatedLabel = newFrame:FindFirstChild("Donated")
if profilePic and profilePic:IsA("ImageLabel") then
profilePic.Image = thumbUrl
end
if displayNameLabel and displayNameLabel:IsA("TextLabel") then
displayNameLabel.Text = displayName
end
if nameLabel and nameLabel:IsA("TextLabel") then
nameLabel.Text = "@"..username
end
if donatedLabel and donatedLabel:IsA("TextLabel") then
donatedLabel.Text = commaValue(donated) -- NO emojis here
end
-- Rainbow effect ONLY for first rank
if rank == 1 then
setRigAppearance(StatueCharacter, userId)
updateStatueOverhead(userId, donated)
if donatedLabel then
-- No emoji here for leaderboard donated label but start rainbow effect
startRainbowEffect(donatedLabel)
end
end
end
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local productDonations = {
[3365355712] = 5,
[3365356166] = 10,
[3365356445] = 25,
[3365356686] = 50,
[3365356862] = 100,
[3365357082] = 250,
[3365357267] = 500,
[3365357652] = 1000,
[3365357952] = 5000,
[3365358193] = 10000,
[3365358594] = 25000,
[3365358783] = 50000,
[3365359225] = 100000,
[3365359633] = 250000,
[3365359908] = 500000,
[3365360294] = 1000000,
}
local donationAmount = productDonations[productId]
if donationAmount then
local success, currentDonated = pcall(function()
return DonationsDS:GetAsync(tostring(userId)) or 0
end)
if success then
local newTotal = currentDonated + donationAmount
pcall(function()
DonationsDS:SetAsync(tostring(userId), newTotal)
end)
end
end
-- Refresh leaderboard immediately on purchase
refreshLeaderboard()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
while true do
refreshLeaderboard()
wait(RefreshTime)
end
Thanks in advance!