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: Retrieving a list from GetChildren()

Previous Thread :: Next Thread 
nuggiebuddie is not online. nuggiebuddie
Joined: 07 Nov 2009
Total Posts: 134
21 Jun 2016 09:06 AM
So to be more clear, I have a function that identifies all children using f = obj:GetChildren(); for x = 1,#f do.....

Say all the children are NumberValues and I want to count all of them and see which value is the highest of the children. How would I go about doing this?

I was thinking about math.max but I can only seem to do a single argument at a time, plus I wouldn't know how to retrieve the value's parent once one is found.
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
21 Jun 2016 09:09 AM
you can use other ways, this is just mine

local HighNum = nil

for i,v in ipairs(f) do
if HighNum and v > HighNum then
HighNum = v
print(HighNum)
elseif HighNum == nil then
HighNum = v
end
end
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
21 Jun 2016 09:11 AM
table = {}
for num,val in pairs(model:GetChildren()) do
table.insert(table,1,val.Value)
end
print(table.sort(table))


r+://393244197r+://393244224r+://393244262
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Jun 2016 09:14 AM
print(math.max(table.unpack(t)))


Report Abuse
nuggiebuddie is not online. nuggiebuddie
Joined: 07 Nov 2009
Total Posts: 134
21 Jun 2016 09:23 AM
So I got the script to properly identify the maximum value, now my only question is how do I find which NumberValue it came from.
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