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

im making a global leaderboard ?

Asked by 5 years ago
Edited by M39a9am3R 5 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

why is this script not working

for i = 1,10 do
    local Sam = script.sample:Clone()
    Sam.Name = i
    Sam.Parent = script.Parent.surfaceGui.Frame.ScrollingFrame
    Sam.UserPos.Text = "["..tostring(i) .. "]"
    Sam.score.Text = "Nil"
    Sam.Username.Text = ""
    Sam.LayoutOrder = i
    script.Parent.SurfaceGui.Frame.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,50*i)
end

function UpdateGui()
    for i,v in pairs(game.Players:GetChildren())do
        local Data = 1 --This is your score.
        local Datastore = game:GetService("DataStoreService"):GetOrderedDataStore("scoreX1")
        Datastore:SetAsync(v.UserId,Data)
    end
    local DataStore = game:GetService("DataStoreService")GetOrderedDataStore("ScoreX1")
    local pages = DataStore:GetStoredAsync(false,10)
    local Data = pages:GetCurrentPage()
    for k,v in pairs(Data) do
        if tonumber(v.key) >= 1 then
            local  Frame = script.Parent.SurfaceGui.Frame.ScrollingFrame:FindFirstChild(tostring(k))
            if Frame then
                Frame.Username.Text = game.Players:GetNameFromUserIdAsync(v.key)
                Frame.score.Text = tostring(v.Value)

            end
        end
    end
end

while true do
    UpdateGui()
    wait(2)
end
0
my eyes hurrt Fad99 286 — 5y
0
Edited for code block. M39a9am3R 3210 — 5y

Answer this question