#Help with Global leaderboard

1 messages · Page 1 of 1 (latest)

static nest
#

i want to make a system where 50 players under a specific datastore will be classified

#

i'm importing the script

#
local DataStoreService = game:GetService("DataStoreService")
local CoinsDataStore = DataStoreService:GetOrderedDataStore("WinsData")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LeaderboardPart = script.Parent
local RefreshRate = 10

local function RefreshLeaderboard()

    local Success, Error = pcall(function()

        local Data = CoinsDataStore:GetSortedAsync(false, 50)
        local RollsPage = Data:GetCurrentPage()

        for Rank, SavedData in ipairs(RollsPage) do

            local UserId = tonumber(SavedData.key)
            local Wins = SavedData.value

            if Wins > 0 then

                local Username = game.Players:GetNameFromUserIdAsync(UserId)

                local NewSample = script:WaitForChild("Template"):Clone()

                NewSample.Parent = LeaderboardPart.SurfaceGui.ScrollingFrame
                NewSample.Name = tostring(Rank)

                NewSample.RankLabel.Text = "#" .. Rank
                NewSample.NameLabel.Text = Username
                NewSample.NumberLabel.Text = Wins

                if Rank == 1 then

                    NewSample.BackgroundColor3 = Color3.fromRGB(255, 213, 0)

                elseif Rank == 2 then

                    NewSample.BackgroundColor3 = Color3.fromRGB(192, 192, 192)

                elseif Rank == 3 then

                    NewSample.BackgroundColor3 = Color3.fromRGB(205, 127, 50)

                else

                    NewSample.BackgroundColor3 = Color3.fromRGB(216, 216, 216)
                end
            end
        end
    end)
end

while true do

    for i, Frame in pairs(LeaderboardPart.SurfaceGui:WaitForChild("ScrollingFrame"):GetChildren()) do

        if Frame.Name ~= "Template" and Frame:IsA("Frame") then

            Frame:Destroy()
        end
    end

    RefreshLeaderboard()

    task.wait(RefreshRate)
end
proud wasp
static nest
#

this should be the result when it works

static nest
frigid forge
#

is k bro im here

static nest
frigid forge
#

uh lemme read

static nest
#

because it doesnt send any error

frigid forge
#

i see error

#

local wins = saveddata.value should be local wins = SavedData.Value

#

sus bro

static nest
#

let me see

static nest
flat iceBOT
#

studio** You are now Level 5! **studio

frigid forge
#

value should be Value

#

if it is an instance then value property is capitalised Value

static nest
#

ok

#

so it should work now?

topaz latch
#

ts impossible

static nest
#

this is the datastore

#

the value 10 is the value of wins

frigid forge
#

ok ok

frigid forge
frigid forge
#

then show the erros

static nest
frigid forge
#

create another script but remove the pcalls