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

Global Leaderboard script not working as intended?

Asked by
3F1VE 257 Moderation Voter
3 years ago

Heres the code :

local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("Time")

local function UpdLB()
    local success, errormessage = pcall(function()
        local dataa = datastore:GetSortedAsync(false,100)
        local timepage = dataa:GetCurrentPage()
        for rank,data in ipairs(timepage) do
            local username = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
            local name = username
            local timee = data.Value
            local isonlb = false
            for i, v in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
                if v.User.Text == name then
                    isonlb = true
                    break
                end
            end
            if timee and isonlb == false then
                local newlbfrm = game.ReplicatedStorage:WaitForChild("PlaceHolder"):Clone()
                newlbfrm.User.Text = name
                newlbfrm.Time.Text = timee
                newlbfrm.Number.Text = "#"..rank
                newlbfrm.Position = UDim2.new(0, newlbfrm.Position.Y.Scale + (.08 * #workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()))
                newlbfrm.Parent = workspace.LB.SurfaceGui.Container.ScrollingFrame
            end
        end
    end)
    if not success then
        warn(errormessage)
    end
end 

while true do 
    wait(10)
    for _, frame in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
        frame:Destroy()
    end
    UpdLB()
    print("updated")
    wait(10)
end

I have a running OrderedDataStore with data on it This code shows no erros but doesnt work as intended?

Answer this question