Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I am making a Donation GUI leaderboard and leaderboard is not showing on client but on server side?

Asked by 2 years ago
Edited 2 years ago

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.

0
Can you please instead of giving us the game and pretty much asking us to fix it for you, quite possibly could you just show us the code, also the directories and what goes wrong? Antelear 185 — 2y
0
Yes I agree with you but the code is big and also I tried fixing it many times and I know I have to use remote event for this but I am not unable to code it in right way. danger_wolf8 0 — 2y
0
Yeah but can you please do so anyways? if you need more help then add me on discord: Ante#6969 Antelear 185 — 2y
0
Username is invalid but I seriously need help :( I am stuck at final moment. danger_wolf8 0 — 2y

Answer this question