Help with creating folders for ClassNames!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to create 1 folder for every part.ClassName that is in the workspace.
And when a new part is created it creates a folder once with that parts class name

  1. What is the issue? Include screenshots / videos if possible!

I’m not sure how to check if a folder with that parts classname already exists or when a parts is added that a folder with that parts classname exist

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

No one was able to help and nothing on the dev hub or discord / youtube.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block
for Number, Instance1 in pairs(workspace:GetDescendants()) do
	Boolean, Nil = pcall(function()
		if Boolean then
			local FindFirstChildOfClass = workspace:FindFirstChildOfClass("Folder")
			if not FindFirstChildOfClass then
				local Folder = Instance.new("Folder")
				Folder.Name = Instance1.ClassName
				Folder.Parent = workspace
				if FindFirstChildOfClass.Name == Instance1.ClassName then
					print("Gots")
				end
			end
		elseif Nil ~= nil then
			warn(Nil)
		end
	end)
end

workspace.ChildAdded:Connect(function(ChildAdded)
	for i, v in pairs(workspace:GetChildren()) do
		if not workspace[v.ClassName] then
			local Folder = Instance.new("Folder")
			Folder.Name = ChildAdded.ClassName
			Folder.Parent = workspace
			ChildAdded.Parent = Folder
		else
			ChildAdded.Parent = workspace[ChildAdded.ClassName]
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

This is my problem I hope some of you can do something to help.

I want to create a Folder for every different ClassName in workspace

local ClassNames = {}
local Folder = Instance.new("Folder", workspace)
Folder.Name = "Classes"


for i,v in pairs(workspace:GetDescendants()) do
	if not table.find(ClassNames, v.ClassName) then
		table.insert(ClassNames, v.ClassName)
		local _Folder = Instance.new("Folder", Folder)
		_Folder.Name = v.ClassName
	end
end


workspace.ChildAdded:Connect(function(Child)
	if not table.find(ClassNames, Child.ClassName) then
		table.insert(ClassNames, Child.ClassName)
		local _Folder = Instance.new("Folder", Folder)
		_Folder.Name = Child.ClassName
	end
end)

Yes but that does not work because I want to parent the part that its find with or without a folder to it to that folder with its calssname but it does not work when I try

Work on your english and try again?, Im not sure what you want

Do you want

Workspace
    - Part
        - Part1
    - Model
        - Model1
    - IntValue
        - IntValue1

yep, yep please please must have need lust for it loathe roblox (Yes!)

Ok so modify it and make it happen

I have but it did not move the parts