ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 02:07 PM |
Ranking the highest money in the server on top and lowest on bottom. Is there anyway to do so?
+1 Forum post |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 05 Nov 2016 02:40 PM |
Monies = {}
for _,player in pairs(game.Players:GetPlayers()) do local money = player.leaderstats:FindFirstChild("Money") table.insert(Monies,{player.Name,money.Val} end
table.sort(Monies)
for _,v in pairs(Monies) do print(v[1],v[2]) end
|
|
|
| Report Abuse |
|
|
ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 02:55 PM |
Like have it show them on a gui.
+1 Forum post |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 05 Nov 2016 02:56 PM |
I gave you all you need :) put the gui text as v[1] and v[2]
|
|
|
| Report Abuse |
|
|
|
| 05 Nov 2016 02:56 PM |
@Soybeen "attempt to compare two table values" on the sort line. |
|
|
| Report Abuse |
|
|
ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 02:57 PM |
LocalScript or Normal Script?
+1 Forum post |
|
|
| Report Abuse |
|
|
ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 03:02 PM |
Would it be like this: Monies = {}
for _,player in pairs(game.Players:GetPlayers()) do local money = player.leaderstats:FindFirstChild("Money") table.insert(Monies,{player.Name,money.Val}) end
table.sort(Monies)
for _,v in pairs(Monies) do script.Parent.F.Text = v[1] script.Parent.S.Text = v[2] script.Parent.T.Text = v[3] script.Parent.F.Text = v[3] end
+1 Forum post |
|
|
| Report Abuse |
|
|
ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 03:03 PM |
oops not script.Parent.F.Text = v[3] I meant script.Parent.Fo.Text = v[4]
+1 Forum post |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2016 03:04 PM |
local players = game.Players:GetPlayers() table.sort(players,function(a,b) return a.leaderstats.Money.Value>b.leaderstats.Money.Value end)
for _,player in next,players do print(player.leaderstats.Money.Value) end
--should be sorted by richest to poorest |
|
|
| Report Abuse |
|
|
ASAP_Bang
|
  |
| Joined: 21 Jan 2013 |
| Total Posts: 116 |
|
|
| 05 Nov 2016 03:06 PM |
I want it to change a text on a Text Label the Richest Players Name and their Cash. And ranked Richest to poorest. There is 4 Text Labels because the max people is 4.
+1 Forum post |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 05 Nov 2016 03:37 PM |
Ah yep I attempted to sort a table of tables Dumb me.
|
|
|
| Report Abuse |
|
|