# How do I rotate a part while also rotating the parts inside of it?

How do I rotate a part while also rotating the parts inside of it? I can do this by rotating it with the roblox rotate tool, but I cannot do it with a script. I’ve tried many times to try and solve it but it has been to no avail.

1 Like

Make all the other parts welded to the part that is rotating. Make it so they are unanchored. If you continue have problems, could you please give me a script to look at? That would be really helpful.

I tried this, the parts are welded together with WeldConstraints and I am doing “part.Orientation = Vector3.New(X,X,X)” It only moves the single part though and not the part inside of it.

Could you send a video of what is happening?

Did you check this as well?

You can use a regular weld, or motor6D. After that you can adjust the C0 so that it rotates by weld.

e.g

``````weld.C0 = weld.C0 * CFrame.Angles(0,1,0)
``````

Yes they are also unanchored I don’t think a video would help. Am I supposed to be using Vector3 for changing orientations?

Ok, I will try that. I will tell you if it works.

It still didn’t work, it rotates correctly with Roblox rotate but a script just rotates the single part.

It doesn’t even move at all now.

Weld everything inside the part to it, that way when you rotate the part everything else follows.

``````local function WeldDescendants(part)--Function that welds all part's descendants to it
for i, v in pairs(part:GetDescendants()) do --Loop through descendants
if v:IsA("BasePart") then
v.Anchored = false
local weld = Instance.new("WeldConstraint")
weld.Part0 = v
weld.Part1 = part
weld.Parent = v
end
end
end
WeldDescendants(part)
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(90), 0) --Rotate part 90 degress onthe Y axis
``````
2 Likes

That’s because they are only affected by CFrames. So, you need to use CFrame to rotate the part in order for it to work.

2 Likes