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?
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?
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")
for grouping a model you can just give any table that consists of any instance
Thats a good idea!
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
No that would definitely not work
You could do instance.new("Model") and then parent the parts to your new model
...And to ungroup, parent it back into workspace or some other directory.
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
Hmm thats a good idea, thnaks!