Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way to ungroup and group some Instances via a script?

Can I do

game.Workspace.Part1 and game.Workspace.Part2

and then do something to group them together and get a model and ungroup it?

5 comments

1

No that would definitely not work

1

You could do instance.new("Model") and then parent the parts to your new model

1

...And to ungroup, parent it back into workspace or some other directory.

0

You could try making a instance.new ("Model") as Spurjeedd said and you could use a i,v in pairs loop getchildren. Like @Xx_FROSTBITExX said you can parent it back to the workspace to ungroup it

0

Hmm thats a good idea, thnaks!

1 answer

Yeah there is a way, you can make some functions to do it, here is how I did it:

function UngroupModel(model)
	local newParent = model.Parent
	
	for i,v in pairs(model:GetChildren()) do
		v.Parent = newParent
	end
end

function groupModel(PartsTable, ModelName)
	local modelParent = Instance.new("Model",workspace)
	modelParent.Name = ModelName
	
	for i,v in pairs(PartsTable) do
		v.Parent = modelParent
	end
end


local ModelIWantToUngroup = workspace.Model

UngroupModel(ModelIWantToUngroup)

local PartsIWantToGroup = {
	workspace.Part1,
	workspace.Part2
}

groupModel(PartsIWantToGroup, "MyPartsModel")

2 comments

0

for grouping a model you can just give any table that consists of any instance

0

Thats a good idea!

This discussion is preserved as it was. New answers, comments, and votes are closed.