Donate Leaderboard Not Working

Hi there Devs! So I am trying to make a Donation Leaderboard. I have seen a tutorial for it and followed everything. It did not work.

So first off:

What am I trying to achieve?
I am trying to make a donate leaderboard so basically when a person donates, they get up on the leaderboard. This leaderboard includes the different donate buttons with different values

Second:
How is my leaderboard oraganized and what scripts am I using?


(EVERY BUTTON HAS THIS SCRIPT WITH A DIFFERENT DEVELOPER ID)

> local ReplicatedStorage = game:GetService("ReplicatedStorage")
> local remoteEvent = ReplicatedStorage:WaitForChild("Purchase")
> local MarketplaceService = game:GetService("MarketplaceService")
> local player = game.Players.LocalPlayer
>  
> local productID = 0 
>  
> player.PlayerGui.DonationGui["5"].Textbutton.MouseButton1Click:Connect(function()
> 	MarketplaceService:PromptProductPurchase(player, productID)
> end)

(The script i’m using for the above screenshot)

> local lbData = game:GetService("DataStoreService"):GetOrderedDataStore("Board")
> 
> function AddCommas(num)
> 
> return tostring(math.floor(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
> 
> end
> 
> function Update()
> 
> local frames = workspace.Leaderboard.SurfaceGui.ScrollingFrame:GetChildren()
> 
> for v,v in pairs(frames) do
> 
> if v:IsA("Frame") then
> 
> v:Destroy()
> 
> end
> 
> end
> 
> for _,plr in next, game:GetService("Players"):GetPlayers() do
> 
> pcall(function()
> 
> ibData:UpdateAsync(plr.UserId, function() return plr:FindFirstChild("leaderstats"):WaitForChild("Donation").Value end)
> 
> end)
> 
> end
> 
> local data = lbData:GetSortedAsync(false,10)
> 
> local page = data:GetCurrentPage()
> 
> for rank, info in next, page do
> 
> local frame = script.Parent.Sample:Clone()
> 
> frame.Visible = true
> 
> local plrName = game:GetService("Players"):GetNameFromUserIdAsync(info.key)
> 
> frame:WaitForChild("Place").Text = "#"..rank
> 
> if rank == 1 then
> 
> print("gold")
> 
> frame.BackgroundColor3 = Color3.new(0.854902, 0.647059, 0.12549)
> 
> elseif rank == 2 then
> 
> print("silver")
> 
> frame.BackgroundColor3 = Color3.new(0.752941, 0.752941, 0.752941)
> 
> elseif rank == 3 then
> 
> print("bronze")
> 
> frame.BackgroundColor3 = Color3.new(0.690196, 0.552941, 0.341176)
> 
> else
> 
> print("white")
> 
>  frame.BackgroundColor3 = Color3.new(1, 1, 1)
> 
> end
> 
> frame.Username.Text = plrName
> 
> frame.Value.Text = AddCommas(info.value)
> 
> frame.Visible = true
> 
> frame.Parent = workspace.Leaderboard.SurfaceGui.ScrollingFrame
> 
> end
> 
> end
> 
> while true do
> 
> Update()
> 
> wait(15)
> 
> end

(This script is supposingly used for updating the leaderboard)


The Donate Buttons are in ScreenGUIs but they are Adorneed with the ‘Shop’ part

Any help please??

1 Like

Where is your ProcessReceipt function? You must have exactly one ProcessReceipt function to handle developer product purchases.

Also adding a script into each button is redundant. It’s better to use one script and perhaps include an IntValue inside each button specifying the ID of the product. That way you can loop through the buttons and add event connections as so:

for _, button in pairs(frame:GetChildren()) do
      button.MouseButton1Click:Connect(function()
            local productID = button:FindFirstChild("ID")
            MarketplaceService:PromptProductPurchase(player, productID)
      end
end

Is it okay if you tell me how to implement this? Well, what I ment is, do I have to modify it and where do I put it? Sorry if it’s alot to ask!

This is a useful resource which includes sample code at the bottom of the page : MarketplaceService | Documentation - Roblox Creator Hub

Basically, in your current implementation, no purchase is registered by the server because there’s no function that’s actively listening for developer product purchases. You need to create one function that handles all dev product purchases inside a server script.

1 Like

Have you enabled Http Requests? This might be why or it might be because there isn’t a ProcessReceipt?

1 Like

I have no clue what all that is suppose to do and how to modify it. I tried reading the whole thing but my scripting skills are just too downhill. Also I only know basics and seeing all this is just gibberish for me since my knowledge is just dead. What do you suggest for a developer like me without scripting experience?

Or another thing, is there a simpler way to do this?

For someone without scripting experience, I recommend that you take on a simpler project to develop your skills in scripting first. Diving into Datastores right off the bat might overwhelm you.

Also, if you find yourself copying code line by line from a tutorial, you aren’t learning anything. The concepts used in the link I shared are not super complex, but they illustrate how to use ProcessReceipt correctly.

I should mention that there is no way of getting around using ProcessReceipt if you want to use dev products. Roblox requires that you handle the requests and return if they have passed or not and this can only be done by having a ProcessReceipt function.

1 Like

I understand. I’ll try my hardest learning the process until I have some skill scripting. Thing is, I cannot really put the game on hold. I mean, sure. The leaderboard is totally optional since I am making a hangout game. But, I really want some good experience for the people!

I’d argue that writing complex scripts without proper background/experience is less efficient than taking the time to properly understand core scripting concepts before diving into making a game.

That’s just my two cents though. You’re free to proceed however you wish, but if you ever find yourself relying heavily on tutorials/other people spoon-feeding you code, then you’ll find yourself consistently disappointed. Plus, it’s much more fulfilling and rewarding when you complete something on your own rather than finding the answer online/from someone else. It’s well worth the extra effort of learning scripting properly.

2 Likes