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

How can I treat a group of objects as one?

I can do what I want to do with relative ease when its one object, but when its a model of multiple it gets challenging. Is it possible to treat a model like an object with things like CFrame, etc?

2 comments

0

I just highlight all the objects, and then just union them.It works for me...

0

replied and edited my answer

4 answers

Let's pretend we want to change the transparency of all parts in a model.

-- Getting the Model's Children (Only the parts with the Model as its parent)

for Index,Value in pairs(Model:GetChildren()) do
	if Value:IsA("Part") then
		Value.Transparency = .5
	end
end

-- Getting the Model's Descendants (All of the Model's parts)

for Index,Value in pairs(Model:GetDescendants()) do
	if Value:IsA("Part") then
		Value.Transparency = .5
	end
end
for i, v in pairs(workspace.House:GetDescendants()) do 
    if v.ClassName == "Part" then -- all the stuff in workspace that is a part

        v.Position = v.Position + Vector3.new(0, 0, 100)
    end -- line 1
end -- line 2

4 comments

0

well yes, i can do something like that, but say the parts are in something like a house formation. would it be possible to move the house to a different location without deforming the original shape of the house?

0

yes, one moment

0

done

0

you could use :MoveTo() as well

I know this is already answered with 2 answers, but I can't let you go on thinking raid6n's answer is a good idea.

So if everything in your house is inside the house model, there is an extremely simple way to move the entire model intact:

local model = workspace.House
model:SetPrimaryPartCFrame(CFrame.new(0, 500, 0))

It is that simple. The only thing you would need to do is set your model's primary part, and if you haven't already done this, I would recommend you make a small part welded to the center of the model that is invisible and cancollided false.

You can also union the parts and basically make them forcefully become one part altogether.

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