for M,B in pairs(mainFolder:GetChildren())do local A=B.Name if string.match(A,"\068\101\115\116\105\110\097\116\105\111\110 ")then table.insert(destinationList,A)end end local M={}repeat local B={nil;math.huge}for M,A in pairs(destinationList)do local d=string.split(destinationList[M]," ")local Q=tonumber(d[2])if Q<B[2]then B={M,Q}end end table.insert(M,destinationList[B[1]])destinationList[B[1]]="\068\101\115\116\105\110\097\116\105\111\110 \057\057\057\057\057\057"until#M==#destinationList
-- Get the valid destinations by checking their name for the string "Destination " (with a space at the end).
for index, value in pairs(mainFolder:GetChildren()) do
	local valueName = value.Name
	if string.match(valueName, "Destination ") then
		table.insert(destinationList, valueName)
	end
end

local sortedList = {}
repeat -- Sort the list
	local lowestValue = { nil, math.huge }
	-- Table describing the index of the destination of the lowest value, followed by its value.
	for index, value in pairs(destinationList) do
		local nameSplit = string.split(destinationList[index], " ") -- Split the name to isolate its destination number
		local stringToNumber = tonumber(nameSplit[2]) -- Convert the destination number to an actual number
		if stringToNumber < lowestValue[2] then
			lowestValue = { index, stringToNumber } -- Overwrite the lowestValue table with the new lowest value.
		end
	end
	table.insert(sortedList, destinationList[lowestValue[1]]) -- Insert the lowest value into the sorted list
	destinationList[lowestValue[1]] = "Destination 999999" -- Don't remove the lowest value because it will end the loop early.
until #sortedList == #destinationList -- Repeat until the sorted list has all the destinations.
