Just to add to this, a name sort like this should suffice
table.sort(plotTable, function(a,b)
local name1 = tonumber(a.Name:match("%d+"))
local name2 = tonumber(b.Name:match("%d+"))
return name1 < name2
end)
Where plotTable
is the name of the varaible that contains a table of all the children in the Plots folder
This is a simple ascending sort method. What this those is when it begins to compares 2 indexes, it gets the name of the part and gets only the numbers in it, hence why there is "%d+"
, and since it’s a string, it’ll need to be converted to a number before comparison.
This was my result using it
First print was before sorting and second was after sorting. Hopefully it should do what you require, if you need them in descending order, just change the <
to a >
@MightyDantheman Yours can work as well if @OP has it set up so the prefix is always the same, but mine ensures it’ll always compare the numbers in the event that one of the names is different, Plot1
instead of Plot 1
or plot 1
instead of Plot 1
, which will order it differently due to how Roblox’s default sorting method accounts for ASCII codes, and lowercase and uppercase letters have different codes, so it would require to lowercase the names before comparision
table.sort(plotTable, function(a,b)
return a.Name:lower() < b.Name:lower()
end)
In the end it depends on how they have it set up