#Can someone help me with my global leaderboard script?

1 messages · Page 1 of 1 (latest)

raven otterBOT
#

studio** You are now Level 3! **studio

onyx fractal
#

local DS = game:GetService("DataStoreService")

local PlayerCoins = DS:GetOrderedDataStore("PlayerCoins")

local Item = script:WaitForChild("Item")

local ScrollingFrame = script.Parent.Board.SurfaceGui.ScrollingFrame

game.Players.PlayerAdded:Connect(function(plr)
local Coins = plr:WaitForChild("leaderstats"):WaitForChild("Coins")

while true do
    task.wait(10)
    --[[This sets the value in the Datastore based on the PlayersUserId
    and the earnt Coins of the Player]]
    local success, errormsg = pcall(function()
        PlayerCoins:SetAsync(plr.UserId, Coins.Value)
        print("line 16 UpdateLeaderboard works")
    end)

    if not success then
        warn(errormsg)
    end
end

end)

while true do
task.wait(10)
local success, pages = pcall(function()
return PlayerCoins:GetSortedAsync(false, 10)
--This returns a dictionary full of entries with descending order]]
end)

if success then
    local entries = pages:GetCurrentPage()

    for rank, entry in pairs(entries) do
        --[[This Clones the Item, gets the username from the UserId
        and sets the rank name and value equal to the TextLabels.Text]]
        local ClonedItem = Item:Clone()

        local username = game.Players:GetNameFromUserIdAsync(entry.key)
        
        if username then
            ClonedItem.Username.Text = username
        end
        
        ClonedItem.Rank.Text = rank
        ClonedItem.Value.Text = entry.value
        
        ClonedItem.Parent = ScrollingFrame
        
    end
end

end

while true do
for i, children in pairs(ScrollingFrame:GetChildren()) do
if children:IsA("UIListLayout") then
print("UIListLayout")
else
children:Destroy()
end

    task.wait(10)
end

end

onyx fractal
#

i didnt touch it yet lol. im gonna think of a way to fix it

onyx fractal
onyx fractal
#

I have a second problem tho game.Players:GetNameFromUserIdAsync(entry.key) thinks im an unknown user on my other acc (Main acc)

onyx fractal
#

I FIXED IT

#

YESSSSSSSSSSSS