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!
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!
local IntFolder = script.Parent.ValueFolder -- Enter the path of your folder
local Highest = 0
local HighestObject
for _, v in pairs(IntFolder:GetChildren()) do
if v:IsA("IntValue") then
if v.Value > Highest then
Highest = v.Value
HighestObject = v
end
end
end
print(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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
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 Did it work?
It worked! Thanks for your help!