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

I want to make a custom leaderboard but I am having trouble?

Asked by 4 years ago
Edited 4 years ago

currently I am making a custom gui which takes a folder of int values and displays them from highest to lowest.

the gui has 10 textlabels to display each int value

each int value's name has a players name and its value is a number.

the server is taking care of the int values themselves so they are not the current concern only the gui.

im trying to get a table with two things each index, the int values name and its number but its not working out. heres the script:

local numindex = 1
local slotindex = 1
local leadertable = {}


function maketable()
    leadertable = {}
    numindex = 1
    local list = game.ServerScriptService.LeaderStats.List:GetChildren()
    for i = 1, #list do
        table.insert(leadertable,numindex,list[i].Value)
        numindex = numindex + 1
    end
    print(unpack(leadertable))
end


while true do
    wait(3.1)
maketable()
end

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

if you need any more explanation lmk in the chat

local list = game.ServerScriptService.LeaderStats.List:GetChildren()

myTable = {}

--add all the values to inside list into myTable
for index, IntValue in pairs(list)do
    print(IntValue.Name, " ", IntValue.Value)
    myTable[IntValue.Name] = IntValue.Value -- add info to table
end

--print out the values in myTable
for playerName, value in pairs(myTable )do
    print(playerName, " ", value)
end 
Ad

Answer this question