You're essentially searching for the same result that this similar code produces for finding a maximum value:
local function findMax(array)
local max = array[1]
for i = 2, #array do
if (array[i] > max) then
max = array[i]
end
end
return max
end
print( findMax {5, 10, 15} )
You would just apply this to your number value objects. The logic stays the same; you just have to modify the code to fit your specific case. Example:
local function findMax(array)
local max = array[1].Value
for i = 2, #array do
if (obj[i].Value > max) then
max = obj[i].Value
end
end
return max
end
print( findMax {IntValue, IntValue, IntValue} )
If you want to find the reference to the actual number value object that contains the "max number," then you could just change the max variable to represent array[1] instead of array[1].Value and reassign new max values to the object instead of the object's value.
1 comment
You could try doing them all two at a time and just keeping the greatest value each time. Use :GetChildren and if the value is greater than the previous winner then set it as the new winner and move to the next value