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: How do I find the player with the biggest amount of points?

Previous Thread :: Next Thread 
KZskychi is not online. KZskychi
Joined: 19 Apr 2012
Total Posts: 202
10 May 2017 03:40 AM
Alright, so I have this script below:


for _, players in pairs (game.Players:GetPlayers()) do
local pistol = game.ServerStorage.Pistol:Clone()
pistol.Parent = v:WaitForChild('Backpack')
end

What I want to find out is, In 60 seconds, which player has the largest amount of points.

The leaderboard is in the player like this: Player.leaderstats.Points

How do I find this out?
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
10 May 2017 03:43 AM
local p = game.Players:GetPlayers()

table.sort(p,function(a,b) return a.leaderstats.Points.Value > b.leaderstats.Points.Value end)

local player = p[1]




Report Abuse
KZskychi is not online. KZskychi
Joined: 19 Apr 2012
Total Posts: 202
10 May 2017 03:47 AM
I have more than 2 players in the game.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
10 May 2017 03:52 AM
And?


Report Abuse
AlreadyPro is not online. AlreadyPro
Joined: 24 Feb 2012
Total Posts: 2463
10 May 2017 06:45 AM
loooooooooool


Report Abuse
graveyardposse is not online. graveyardposse
Joined: 23 Oct 2008
Total Posts: 2565
10 May 2017 07:04 AM
hahahaha
Report Abuse
rankyn2 is not online. rankyn2
Joined: 29 Dec 2016
Total Posts: 40
10 May 2017 07:07 AM
Mhmmm..
Report Abuse
Cyrakohl is not online. Cyrakohl
Joined: 09 Nov 2014
Total Posts: 3197
10 May 2017 07:08 AM
What in tarnation


R$10,012
Report Abuse
RogueMage is not online. RogueMage
Joined: 28 Jan 2012
Total Posts: 1235
10 May 2017 11:06 AM
OP, That function he used in the table sorts players from largest to smallest based ## ##### ####### the sort function could take an argument of a function that allows you to compare two values and return the one that's larger (or the one you want to go first) Does that explain it?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
10 May 2017 11:39 AM
local players = game.Players:GetPlayers() table.sort(players,function(player1,player2) return ################################ > ################################ end) for i,v in next, players do print(v,'is player number',i) end
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
10 May 2017 11:42 AM
i give up on this filter fr


Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 May 2017 12:17 PM
I normally define the comparator outside.

function compareTo(a, b)
return (a.leaderstats.Points.Value > b.leaderstats.Points.Value)
end

local p = game.Players:GetPlayers()
table.sort(p, compareTo)
print(p[1].Name.." has the most points")
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 May 2017 02:13 PM
If you just want the player with the most points, DO NOT USE TABLE.SORT.
Just iterate over the table and record who has the highest.
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