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

Global Leaderboard Gui ?

Asked by 3 years ago
Edited 3 years ago

i found an issue when every time the countdown ends it clones i how i want but when the count down ends again it clones again but it does not destroy the old one

local DataStoreService = game:GetService("DataStoreService")
local TimeODS = DataStoreService:GetOrderedDataStore("lbSaved_1")


local timeUntilReset = 10


while wait(10) do


    timeUntilReset = timeUntilReset - 1

    script.Parent.Parent.Countdown.Text = timeUntilReset


    if timeUntilReset == 0 then

        timeUntilReset = 10


        for i, plr in pairs(game.Players:GetPlayers()) do

            TimeODS:SetAsync(plr.UserId, plr.leaderstats.Fish.Value)
        end

        for i, leaderboardRank in pairs(script.Parent:GetChildren()) do

            if leaderboardRank.ClassName == "Frame" then
                leaderboardRank:Destroy()
            end
        end


        local success, errorMsg = pcall(function()

            local data = TimeODS:GetSortedAsync(false, 5)
            local coinsPage = data:GetCurrentPage()

            for rankInLB, dataStored in ipairs(coinsPage) do


                local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
                local coins = dataStored.Value


                local template = script.Template:Clone()

                template.Name = name .. "Leaderboard"

                template.PlrName.Text = name

                template.Rank.Text = "#" .. rankInLB

                template.Minutes.Text = coins

                template.Parent = script.Parent             
            end         
        end)
    end
end

0
You answered your own error in your post. The error is that you can't store things from the client, They need to be from a serverscript. kegirosou 17 — 3y

Answer this question