generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Easiest way to make a custom leaderboard GUI?

Previous Thread :: Next Thread 
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 05:30 PM
So im creating a custom leaderboard or playerlist GUI and am wondering how would I create a leaderboard GUI that sorts by the player's level?

-I have a level stat inside the player.
-It recreates upon a player entry, player leave, and player level change.

I did have a complex version of compiling the player levels into a table, searching and adding the player to the leaderboard if it's level value matched the max value in the table, then removing their value from the table to find the next highest level to add the leaderboard. Got lots of bugs in it. What is an easier way to sort?
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 06:04 PM
Still stuck
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 06:12 PM
function sort()

local tab = {} --Store the Levels in here, temporarily so every time the function is called, it's Refreshed
local currentPos = 0 --Gonna use this for Positioning

for i, v in pairs(game.Players:GetPlayers()) do
table.insert(tab, v.leaderstats.Level)
end

repeat
local highest = math.max(tab:unpack()) --I think it's :unpack() haven't used for ages
--place the 'highest' at the 'currentPos'
currentPos = currentPos + wateverAmount

for i, v in pairs(tab) do --I can't remember if table.sort would sort everything from Lowest to Highest or the Opposite
if v == highest then
table.remove(i)
end
end
until #tab == 0

end

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 06:40 PM
So how do I tie the player name to the level?
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 06:57 PM
sry forgot...

local nameTab = {} --before "Tab"

and

inside the 'for' loop (for GetPlayers)
table.insert(nameTab, v.Name)

and then after... well lemme check my scrpt again...

"My Life is going Good... but..."
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
04 Apr 2015 06:59 PM
math.max(tab:unpack()) -

this would be correct in the latest Lua version.

However it is
unpack(tab)
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:00 PM
repeat
local highest = math.max(tab:unpack()) --I think it's :unpack() haven't used for ages

for i, v in pairs(tab) do --in this case we wont need table.sort in anyway... cos we're dealing with Names as well
if v == highest then
--place the 'highest' at the 'currentPos' and use nameTab[i] as the Name...
table.remove(Tab, i) --forgot to give the Table as the 1st Arg XD
table.remove(nameTab, i)
end
end

currentPos = currentPos + wateverAmount
until #tab == 0

good luck ;)

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:00 PM
oh yeah!
cody is right Xd
I keep forgetting...

"My Life is going Good... but..."
Report Abuse
twoolard is not online. twoolard
Joined: 20 Jun 2013
Total Posts: 35
04 Apr 2015 07:01 PM
IDK?
Report Abuse
twoolard is not online. twoolard
Joined: 20 Jun 2013
Total Posts: 35
04 Apr 2015 07:02 PM
YEAH!
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 07:03 PM
I'm gonna try this and i'll deliver the results.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:04 PM
sure do :)
I feel relieved wen I make Code for someone to help them and they use it... cos if no one used it, I'd feel like I wasted my time Scripting it :/

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 07:05 PM
Also how would this be done in filteringenabled? Im gonna turn it off for now, but I set up a lot of stuff for that being on
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:08 PM
same...
it's not a localscript :P
but if u mean, wen say a Person's Level changes, just do inside the leaderstat Creation Script

indexUrLevelValue.Changed:connect(theFunctionIGaveU)

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 07:18 PM
hmm... I thought I changed the creation script to local for a reason I can't remember... I'll do a few tests but I believe you are right.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:21 PM
dont worry, I'm always right XD
kinda...
rarely make mistakes XD

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 07:23 PM
Hoping on it
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
04 Apr 2015 07:26 PM
Also, I am wanting it to change every time someone's level changes for obvious reasons, but in the script it only gathers the players using in pairs once, how would i make it regather to fit new players
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Apr 2015 05:06 AM
well, the chunk I gave is a Function, meaning that:
the way I created the Table (made it local) it would be made every time the function is called, so dont worry, call the function everytime someone joins... but let their Data be Loaded 1st!

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
05 Apr 2015 01:28 PM
Yes this is exactly what I did, which was annoying to figure out to do, which I had to create a connection for loading the gui when you first join, and then disconnecting the connection when another player's character joined, along with calling the function, which is now the new connection, so that it be disconnected each time a new player joins, because im 99% sure if you do not disconnect the gathering the player's level stat it would run another function alongside it, doing the same thing. Tricky stuff.

Also for the results of the gui script, it will only work on a normal script if filtering enabled is off :/. I won't receive any errors it just doesn't create the list last time I checked
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Apr 2015 02:17 PM
wait, so in short... it doesn't Work as expected? :/

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
05 Apr 2015 02:19 PM
If expected is running in a normal script with filtering enabled, then yes.
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
05 Apr 2015 02:20 PM
But thanks alot for helping, I needed some expert experience to create the table properly.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Apr 2015 04:55 PM
np ;)
btw, wat did ya say was wrong?
it doesn't display them properly?

"My Life is going Good... but..."
Report Abuse
lunarvoidknight12 is not online. lunarvoidknight12
Joined: 09 Apr 2011
Total Posts: 214
05 Apr 2015 09:06 PM
It doesn't even begin to display with filtering on. Maybe normal scripts can't access a player's gui?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image