Leaderboard script

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.Money.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:GetChilderen()) do
        local Data = 1
        local DateStore = game:GetService("DataStoreService"):GetOrderDataStore("MoneyX1")
        DateStore:SetAsync(v.UserId,Data)
        end
        local DateStore = game:GetService("DataStoreService"):GetOrderDataStore("MoneyX1")
        local Pages = DateStore:GetSortedAsync(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.Money.Text = tostring(v.Value)
                end
            end
        end
end

while true do 
    UpdateGui()
    wait(2)
end

dis needs to be a leaderboard so what did i do wrong in this script my Value is Money

1 Like

Could you try trowing in a bunch of print statements and tell me which of them print? Also, you’re trying to get data about top 10 players waay faster than the limits are, instead of 2 seconds, try calling the function each 60+ seconds.

1 Like

it is this line that doesn work
Sam.Layoutorder = i

Oh yeah I see, it’s supposed to be LayoutOrder, not Layoutorder

2 Likes

now this one doesnt work
for i,v in pairs(game.Players:GetChilderen()) do

You wrote it as :GetChilderen() instead of :GetChildren() :+1:

2 Likes

know this doesnt work
local DateStore = game:GetService(“DataStoreService”):GetOrderDataStore(“MoneyX1”)

It’s supposed to be :GetOrderedDataStore(), not :GetOrderDataStore()

Note: Output is always your best friend, go through the errors and check for spelling mistakes

3 Likes

this?
local Pages = DateStore:GetSortedAsync(false,10)
is ther somthing worng in here?

Nope, this line seems to be alright

this is wrong (30ch)
UpdateGui()

The only issue I see here is that you’re calling it too fast

no i made this yesterday but i cant seem to find the problems

Yeah, there are a bunch of spelling mistakes through the script, open your output and either show me the errors or go through them and make sure everything’s spellec correctly

only look at the errors down ik what the error above that is

Oh, are you in a team create with someone? This error appears if you’re not the owner of that team create.

i am the only one working on it

Did you enable studio API service access in the game settings?

where do i see that ? (30characters)

There’s “Game Settings” button with a blue gear icon under the Home tab in roblox studio. Once you click it a window should appear - on the left side, there should be a button called Options.


(I can’t enable/disable mine, because I haven’t published the game)