Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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.

3 comments

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.

0

YelloMynamesZak Did it work?

0

It worked! Thanks for your help!

This discussion is preserved as it was. New answers, comments, and votes are closed.