Hello Devs, I am making a Donation GUI with the leaderboard and it is working fine but there is a small mistake in it that is, the buttons are visible but the leaderboard isn't visible on the client-side but it is visible on the server-side. I know it can be fixed with a remote event but I am still unable to do that. Looking for your help.
-- Server Script Service-- local donateAmounts = {500, 1000, 2000, 5000, 10000} local ids = {1210650430, 1210650616, 1210650734, 1210650846, 1210650846} local mps = game:GetService("MarketplaceService") local stg = game:GetService("StarterGui") local dss = game:GetService("DataStoreService") local ods = dss:GetOrderedDataStore("Donators") for i, amount in pairs(donateAmounts) do local donateButton = script:WaitForChild("DonateButton"):Clone() donateButton.Text = amount .. " Robux" donateButton.Parent = stg:WaitForChild("DonateGUI").MainFrame.DonateFrame.DonateList end game.ReplicatedStorage.DonateRE.OnServerEvent:Connect(function(plr, button) local amount = string.gsub(button.Text, " Robux", "") local id = ids[table.find(donateAmounts, tonumber(amount))] mps:PromptProductPurchase(plr, id) end) mps.ProcessReceipt = function(purchaseInfo) local amount = mps:GetProductInfo(purchaseInfo.ProductId, Enum.InfoType.Product).PriceInRobux local success, err = pcall(function() local totalDonated = ods:GetAsync(purchaseInfo.PlayerId) or 0 ods:SetAsync(purchaseInfo.PlayerId, totalDonated + amount) end) return success and Enum.ProductPurchaseDecision.PurchaseGranted or Enum.ProductPurchaseDecision.NotProcessedYet end while task.wait(5) do for i, child in pairs(stg:WaitForChild("DonateGUI").MainFrame.LeaderboardHolder.LeaderboardList:GetChildren()) do if child:IsA("Frame") then child:Destroy() print("DELETED CHILD THAT IS A FRAME: " .. tostring(child.Name)) end end local pages = ods:GetSortedAsync(false, 100) local top = pages:GetCurrentPage() for rank, data in ipairs(top) do local username = game.Players:GetNameFromUserIdAsync(data.key) local donated = data.value local leaderboardFrame = script:WaitForChild("LeaderboardFrame"):Clone() leaderboardFrame.Rank.Text = "#" .. rank leaderboardFrame.Username.Text = username leaderboardFrame.Amount.Text = donated leaderboardFrame.Parent = stg.DonateGUI.MainFrame.LeaderboardHolder.LeaderboardList if leaderboardFrame == nil then warn("LEADERBOARD FRAME IS NIL") end print(tostring(donated)) print(tostring(username)) print(tostring(rank)) end end
-- StarterGUI button Handler-- local donateList = script.Parent.MainFrame.DonateFrame.DonateList function handleDonateButton(button) button.MouseButton1Click:Connect(function() game.ReplicatedStorage.DonateRE:FireServer(button) end) end for i, child in pairs(donateList:GetChildren()) do if child:IsA("TextButton") then handleDonateButton(child) end end
donateList.ChildAdded:Connect(handleDonateButton)
Here is the place game you can check it and please fix it https://www.roblox.com/games/8802804169/Donation-GUI-V2 Copy and paste link in another tab.