In Studio, I can create a model by grouping objects with a simple Ctrl+G
:
How can I do the same via script?
In Studio, I can create a model by grouping objects with a simple Ctrl+G
:
How can I do the same via script?
You do something like:
local things = {
game.Workspace.PartOne,
game.Workspace.PartTwo,
game.Workspace.PartThree
}
-- things will be the table we group to.
local masterPart = Instance.new('Folder',game.Workspace)
-- Master part is what we group everything to. Assign it a name if wanted.
masterPart.Name = "Master"
for key, value in pairs(things) do
-- value is the part we are referring to (partone, two, or three.)
value.Parent = masterPart
-- that moves those parts to the master part, and now they're all grouped!
end
Like this:
--set up a list of predefined parts
local Parts = {
workspace.Part
workspace.Ball
workspace["Cubed cube"]
}
--create Model
local Model = Instance.new("Model")
--loop through array Parts and parent each to Model
for _, Part in pairs(Parts) do
--parent Part to Model
Part.Parent = Model
end
This is really awsome that you can take the manual steps and put it as instructions in code to execute for a model but i was woundering if you could do the same thing but union, i need it just to input a vector3 to a group pf parts i know you can do this with ipairs to iterate threw every part but i was wondering if i could make it a union instead?