TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Mar 2015 06:53 PM |
Hi all. I am seeking advice on how to implement a trophy system into my game, that is listing the top 3 players with highest points. I am thinking of something like this.. I would appreciate any suggestions!
for i, v in pairs(game.Players:getChildren()) do for i,x in pairs(v:GetChildren()) do
if v.Name = "Points" then if v.Points.Value == 100 then print(.. v.Parent.Name .."has won the game!") elseif v.Points.Value ~=100 then --something to check the player with the 2nd highest points print("this players has the second best points") --something to check the player with the 3rd highest points print("this players has the 3rd best points")
end end end end
I hope this makes sense. This would be similar to call of duty's Free For All system where it lists the top 3 players after a round in order. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Mar 2015 07:10 PM |
Would using
repeat wait() until Points.Value ~= 100
or something similar achieve what I am looking for here? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Mar 2015 07:15 PM |
| I guess I could use a loop here and have the script iterate counting downwards until it finds a value that is not 100 points. and then so on for the next closest value |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Mar 2015 07:25 PM |
| Surely this shouldn't be as complicated as it seems to me. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
belly460
|
  |
| Joined: 23 Jul 2013 |
| Total Posts: 22 |
|
|
| 02 Mar 2015 08:18 PM |
| You can take all the players and put them in a table. Then you use a block of code to find out who got the highest score. Afterwards, you remove that player from the table and run it again to find the second place. And again with third place and so on. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Mar 2015 08:41 PM |
How should I define the players and points in the table? Would I do:
for i=1, #pointsstable do ?
this is a start..im terrible at tables -------------------------
local pointstable = {}
for _, v in pairs(game:GetService("Players"):GetChildren()) do table.insert(pointstable,v)
end |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Mar 2015 12:48 PM |
| any ideas on how to use a table and check players highest points??? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 03 Mar 2015 01:31 PM |
put into table, sort it and then do table[1] table[2] table[3] http://wiki.roblox.com/index.php/Function_Dump/Table_Manipulation#table.sort
- El, Psy, Kongroo. |
|
|
| Report Abuse |
|
|