How can I sort by number of parts using a script?

Hi, I have a folder with a ton of parts (more than 10,000) and was wondering if there is anyway I can make a script that when the game runs the parts are sorted into 10 different folders so that there are 1000 parts in each?
Cheers,

local Folder = game.Workspace.Folder

for _I = 1, #Folder:GetChildren()/100, 1 do
	
	local NewFolder = Instance.new("Folder", game.Workspace)
	NewFolder.Name = "Folder".._I

	pcall(function()
		for I_ = 1, 100, 1 do
			
			local Children = Folder:GetChildren()[I_*10] 
			Children.Parent = NewFolder
			
		end	
	end)

end
1 Like