|
| 11 Jul 2017 08:49 PM |
and i run math.max on it to find the highest player's damage, but from there how do i get the player with that damage?
playerdamage = {}
for i, player in ipairs(game.Players:GetPlayers()) do table.insert(playerdamage,i,player.leaderstats.Damage.Value) end
local MVP = math.max(playerdamage)
i need MVP to give the PLAYER who did the most damage
make america great again |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 09:13 PM |
gime solutions
make america great again |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 11 Jul 2017 09:16 PM |
playerdamage[#playerdamage]
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 09:16 PM |
elaborate?
make america great again |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 11 Jul 2017 09:24 PM |
local mvp = playerdamage[#playerdamage]
the #playerdamage is the index as long as the items are in order i think
|
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 11 Jul 2017 09:25 PM |
oh wait, nevermind sorry I didn't read this right.
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 09:26 PM |
what is this gonna return? it currently returns the highest value on the table, but i need to extend it to return the owner of that damage value
make america great again |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 09:43 PM |
This isn't perfect but,
function sorter(a,b) if a < b then return true else return false end local MVP = table.sort(playerdamage, sorter)
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 09:48 PM |
what exactly will MVP equal in that instance?
im gonna test it and let you know if it works
make america great again |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2017 10:28 PM |
no luck
make america great again |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2017 12:42 PM |
bump
make america great again |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 12 Jul 2017 12:47 PM |
local MVP, damage=0
for i, player in ipairs(game.Players:GetPlayers()) do if player.leaderstats.Damage.Value > damage then damage = player.leaderstats.Damage.Value MVP = player end end |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2017 12:48 PM |
thank you :)
make america great again |
|
|
| Report Abuse |
|
|