Shortcut for grouping all select parts into a folder

Being able to quickly group parts together into a model is really nice but it would be cool if you could do the same thing but instead it would create a new folder and put all objects into that folder. This would be really useful for when you’ve completed a large project/model and you would like to quickly organize all the models that go into it.

16 Likes

Would prefer action in the explorer’s context menu to do this as well.

Have you tried checking the shortcuts in studio? There are a lot of unassigned options.

Yes, I did check them and I didn’t see one.

Have you tried making a plugin to do this?

Works for OP but not for the context menu item mentioned in post #2 ): Plus, grouping instances together in folders is one of the fundamental use cases for folders, so it’d be more appropriate for it to be an actual feature instead of a plugin. It’d be silly for us to have to create our own plugin to finish an (unintentionally) incomplete feature.

1 Like

Ungroup should work on folders too, that’d be great.

2 Likes

Making a plugin is a lot faster than waiting for a feature to be added into Studio. Why not make the plugin and use it until then?

Making a plugin is a fine temporary fix. The two last sentences in the post you quoted were clarifying that even though it’s possible to work around, it still needs to be a feature.

Eh, they could make it that pressing CTRL+G groups all selected stuff in a Folder anyway.
Pressing CTRL+G when only having a Model/Folder selected would switch the class.
(Internally, if possible, they would literally just have to change the ClassName)

Only issue is: You can’t group certain items together (like a Camera).
Not sure if you should disable the toggling to a Model there or…

Normally I would just group it and use the Converter 3.0 plugin to change the model into a folder, but that plugin crashes studio for some reason.

Sorry to bump this, but I wanted the same thing so I made a really basic plugin:

https://www.roblox.com/library/9809835951/Group-into-Folder

Here’s the code if you want to read it before you install :+1:

local UIS: UserInputService = game:GetService("UserInputService")

function getCommonAncestor(inst: Instance, instances: {[number]: Instance}): Instance | nil
	if inst:IsA("DataModel") then return nil end
	local par: Instance? = inst.Parent

	local function isCommonAncestor(potentialAncestor: Instance)
		for i, v: Instance in ipairs(instances) do
			if v:IsDescendantOf(game) then
				if not v:IsDescendantOf(potentialAncestor) then
					return false
				end
			end
		end
		return true
	end

	if par then
		if isCommonAncestor(par) then
			return par
		else
			return getCommonAncestor(par, instances)
		end
	end
	return nil
end

function groupIntoFolder(...:any)
	local instances: {[number]: Instance} = game.Selection:Get()
	if #instances == 0 then print("F0") return end

	local commonAncestor: nil | Instance

	for i, v:Instance in ipairs(instances) do
		if v:IsDescendantOf(game) then
			commonAncestor = getCommonAncestor(v, instances)
			if commonAncestor then
				break
			end
		end
	end
	if commonAncestor then
		local folder: Folder = Instance.new("Folder")
		for i, inst in ipairs(instances) do
			pcall(function()
				inst.Parent = folder
			end)
		end
		folder.Parent = commonAncestor
		game.Selection:Set({folder})
	end
end

local function ungroupFromFolders(...:any)

	local instances: {[number]: Instance} = game.Selection:Get()
	if #instances == 0 then print("U0") return end

	local folders = {}
	local newSelections = {}
	for i, folder in ipairs(instances) do
		if folder:IsA("Folder") and folder.Parent then
			for j, inst in ipairs(folder:GetChildren()) do
				pcall(function()
					inst.Parent = folder.Parent
					table.insert(newSelections, inst)
				end)
			end
			pcall(function()
				folder:Destroy()
			end)			
		end
	end
	game.Selection:Set(newSelections)
end

local groupAction = plugin:CreatePluginAction("FolderGroup", "Folder Group", "Group into Folder", "http://www.roblox.com/asset/?id=9381635006", true)
groupAction.Triggered:Connect(groupIntoFolder)

local ungroupAction = plugin:CreatePluginAction("FolderUngroup", "Folder Ungroup", "Ungroup from Folders", "http://www.roblox.com/asset/?id=9381635006", true)
ungroupAction.Triggered:Connect(ungroupFromFolders)

Enjoy! Shout out to @buildthomas for the PluginAction tip!

Just a quick tip, there’s a thing called PluginActions: Plugin:CreatePluginAction

If you register these two things as PluginActions, people can assign their own shortcuts to it via the shortcuts menu. It will also extend more naturally to MacOS that way.

I used these in this plugin to allow people to specify the shortcut without needing to know how to code: Plugin to Collapse/Expand all folds in Explorer [warning: use at own risk!]

3 Likes