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 » Scripting Helpers
Home Search
 

Re: Custom Leaderboard

Previous Thread :: Next Thread 
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
23 Jun 2012 10:22 AM
Im working on a custom leaderboard, but how would I get all the players, and sort them into the teams in a Gui?

p = game.Players:GetChildren()
for i = 1,#p do
if p[i].TeamColor == "Bright yellow" then
--The main thing im trying to ask is how would I add the players name without skipping a space or overlapping any other TextLabels?
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
23 Jun 2012 10:29 AM
Maxplayers = 10

team1 = 5
team2 = 5

make 10 textlabels.
Report Abuse
rangersmash is not online. rangersmash
Joined: 18 Nov 2009
Total Posts: 2891
23 Jun 2012 10:31 AM
Trust me. Custom leaderboards are a real pain to update stats.

-[ RS ]-
Report Abuse
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
23 Jun 2012 10:34 AM
*facepalm* @ first post.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
23 Jun 2012 10:35 AM
Right, didn't read post correctly.
Report Abuse
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
23 Jun 2012 10:45 AM
I don't really care how much of a pain it is I just wanna do it. :L
Report Abuse
awas3 is not online. awas3
Joined: 24 Oct 2010
Total Posts: 2854
23 Jun 2012 10:50 AM
I asked the same question a long time ago.
Report Abuse
StrandedEpisode1 is not online. StrandedEpisode1
Joined: 19 Dec 2011
Total Posts: 52
23 Jun 2012 10:51 AM
I will look on this after dinner. Its not really hard actually.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
23 Jun 2012 10:55 AM
p = game.Players:GetChildren();
list = {};
for i,v in pairs(p) do
list[v.TeamColor.Name] = list[v.TeamColor.Name] or {};
list[v.TeamColor.Name][#list[v.TeamColor.Name]+1] = v;
end

--The above will sort them into teams.
--The following will set all players into a single table.

new_list = {};
for i,v in pairs(list) do
for x,y in pairs(v) do
new_list[#new_list+1] = y;
end
end
Report Abuse
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
23 Jun 2012 11:29 AM
Could you perhaps, explain what each line does? Ive never done much with tables.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
23 Jun 2012 12:05 PM
Oh god sure.


p = game.Players:GetChildren();
-- At this point, p will look like {game.Players.blobbyblob,
-- game.Players.SilverNinja14}, etc. It just lists all the players.

list = {};
-- Now 'list' is an empty table.

for i,v in pairs(p) do
-- Creates an iterating loop. This will go through where (i = 1),
-- and (v = game.Players.blobbyblob). Second time through it
-- will be (i = 2) and (v = game.Players.SilverNinja14).

list[v.TeamColor.Name] = list[v.TeamColor.Name] or {};
-- This will initialize a new empty table *inside* the first table.
-- That nested table will have the same name as v.TeamColor.Name.
-- The 'or' operator as I used it in that situation might need an
-- explanation all of its own, so here goes:
--
-- x = y or z; Will set x to the value of y if y is not nil. If y is nil,
-- then it will set x to the value of z.
--
-- The idea in the situation where I used it is that list.< teamcolor>
-- will stay the same if it has been initialized already. Otherwise, it
-- gets set to {} (empty set).

list[v.TeamColor.Name][#list[v.TeamColor.Name]+1] = v;
-- Sets the next open slot in the table to the value of v.
-- It's the same as doing table.insert(list[v.TeamColor.Name], v)
-- except it's faster because it doesn't need to handle all the cases
-- table.insert does. I know what the indices will be.

end
-- duh.



And when you're done, you'll have something that looks like this:

list = {
Bright red = {game.Players.blobbyblob, game.Players.Player},
Bright blue = {game.Players.SilverNinja14}
}
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
23 Jun 2012 12:08 PM
I'll be totes honest. I didn't explain the second part because I got bored. But the first part is the most advanced one. The second one just takes this:

list = {
Bright red = {game.Players.blobbyblob, game.Players.Player},
Bright blue = {game.Players.SilverNinja14}
}


and turns it into this:

list = {game.Players.blobbyblob, game.Players.Player, game.Players.SilverNinja14}

And it stays in the correct order team-wise.
Report Abuse
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
23 Jun 2012 12:09 PM
Very confusing. But helpful. Thanks, ill see what I can do with it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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