Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Order parts in a table in order of position?

Asked by
manith513 121
2 years ago

I have the parts in a model as a table, and I am trying to order them in order of position. Here is my code.

local house1 = game.Workspace.House:GetChildren()
local sortedhouse = table.sort(house1, function(a,b)
    if a:IsA("Script") or b:IsA("Script") then


    else 
        return a.Position.Y > b.Position.Y  

    end


end)

print(sortedhouse)

I check to make sure the items arent a Script as the script containing this is also in the model. There are no error messages however, when I print sortedhouse it prints a nil. Anyone know How I can fix this to properly order the parts from lowest position to Highest?

Answer this question