|
| 31 Jul 2014 05:04 PM |
So I have a model full of number values. And I want to look for the highest value. As in numbers. Like: value1 = 100 value2 = 2 value3 = 9 I want to find value1 cause it's the biggest. |
|
|
| Report Abuse |
|
|
| |
|
|
| 31 Jul 2014 05:06 PM |
local values = model:GetChildren local highestvalue = -1 local highestvalue2 = nil for i = 1, #values do if values[i].Value > highestvalue then highestvalue = values[i].Value highestvalue2 = values[i] end end |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2014 05:06 PM |
local highestValue = math.max(value1, value2, value3) print(highestValue) > 100 |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 31 Jul 2014 05:07 PM |
highest = nil for i, v in pairs(MODEL:GetChildren()) do if (v.ClassName == "NumberValue") then if (v.Value > highest.Value or highest == nil) then highest = v end end end |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2014 05:13 PM |
Actually this might work better:
local highestValue local values = {}
for i, v in pairs(model:GetChildren()) if v.ClassName == "NumberValue" then table.insert(values, v.Value) end end
local highestValue = math.max(unpack(values))
|
|
|
| Report Abuse |
|
|
| |
|
|
| 31 Jul 2014 07:01 PM |
I have no idea if I'm doing it right.. local winnert = Instance.new("Model", script) winnert.Name="PlayerDestroyValues" for i,v in pairs(game.Players:GetPlayers()) do local zxxx = Instance.new("NumberValue", winnert) zxxx.Name="Destroys "..v.Name zxxx.Value = v.Destroys.Value end for i,v in pairs(winnert:GetChildren()) do local person = math.max(v.Value) game.Workspace.Won.Value=string.sub(person.Name,10) end
Now what I'm trying to do is: Make a model in this script. Make all the player's score. I use math.max to find the highest value. Then look for the person with that value. |
|
|
| Report Abuse |
|
|