Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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 

This discussion is preserved as it was. New answers, comments, and votes are closed.