Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I sort the values of several Integer Values from greatest to smallest?

Asked by 4 years ago

I have a folder with 12 integer values in it. As a round goes on the values of said integer values will change. I want to find a way to sort them from greatest to least.

Any help will be appreciated!

1 answer

Log in to vote
1
Answered by
yx10055 57
4 years ago
01local IntFolder = script.Parent.ValueFolder -- Enter the path of your folder
02local Highest = 0
03local HighestObject
04 
05for _, v in pairs(IntFolder:GetChildren()) do
06    if v:IsA("IntValue") then
07        if v.Value > Highest then
08            Highest = v.Value
09            HighestObject = v
10        end
11    end
12end
13 
14print(HighestObject:GetFullName())

This goes through the objects in your folder, checks if they are integer values, checks if their value is higher than the highest value, sets the highest value to their value and sets the highest object to the value.

0
You absolute legend! I'll throw this code in my game and see if it works. If it works I'll accept this answer. YelloMynamesZak 85 — 4y
0
YelloMynamesZak Did it work? yx10055 57 — 4y
0
It worked! Thanks for your help! YelloMynamesZak 85 — 4y
Ad

Answer this question