I’m trying to make a slicing script that slices a mesh into layers using parts, now i am trying to count up from the lowest layer to the highest layer but idk how to do that. The layers are numbered by the parts inside’s Y positions.
Also the current code to loop trough it that i have now is this:
local function GetLowest(tab)
local numtable = {}
for i ,v in pairs(tab) do
if v:IsA("Model") then
table.insert(numtable,tonumber(v.Name))
end
end
table.sort(numtable)
return math.min((unpack(numtable)))
end
for i = 1,#layers do
local layer = GetLowest(layers)
local v = table.find(layers,tostring(layer))
table.remove(layers,v)
print(layer,layers)
end
It’s still unsorted
What i want to do is basically loop trough the model by starting at the lowest number and ending at the highest one in order.
Sorry for bad explanation in original post btw.