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: i have a table with the leaderstats value for each player

Previous Thread :: Next Thread 
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
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
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
11 Jul 2017 09:13 PM
gime solutions

make america great again
Report Abuse
RobuxLife is not online. RobuxLife
Joined: 19 Sep 2012
Total Posts: 13336
11 Jul 2017 09:16 PM
playerdamage[#playerdamage]


Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
11 Jul 2017 09:16 PM
elaborate?

make america great again
Report Abuse
RobuxLife is not online. 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 is not online. 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
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
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
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
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
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
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
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
11 Jul 2017 10:28 PM
no luck

make america great again
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
12 Jul 2017 12:42 PM
bump

make america great again
Report Abuse
Casualist is not online. 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
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
12 Jul 2017 12:48 PM
thank you :)

make america great again
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