How exactly would you rotate all these attachments 90 degrees?

I know that attachments are relative to their parent but is there anyway to basically get all the attachments and rotate them 90 degrees?

And i’m not talking about individually im talking about as like a whole thing without rotating the parent?

1 Like

Hey, hope this helps.

local AttachmentContainer = game.Workspace.AttachmentContainer -- Change this to whatever your part with attachments' name is.

for i, v in pairs(AttachmentContainer:GetChildren()) do
    if v:IsA("Attachment") then
        local Attachments = v
        Attachments.Orientation += Vector3.new(0, 90, 0) -- Change this to whatever Axis you need.
    end
end

If you want an actual animation instead of it just warping there, then do this instead.

local RunService = game:GetService("RunService")
	local AttachmentContainer = game.Workspace.AttachmentContainer -- Change this to whatever your part with attachments' name is.
	
	RunService.Heartbeat:Connect(function(deltaTime)
		for i, v in pairs(AttachmentContainer:GetChildren()) do
			if v:IsA("Attachment") then
				local Attachments = v
				Attachments.Orientation += Vector3.new(0, 1, 0) -- Change this to whatever Axis you need, and change the 1 to your desired speed.
			end
		end
	end)

Yeah I tried this and it’s rotating each attachment individually, which is not what I want

I want it to be rotated as one single unit as if it was a model if that makes sense

Huh? What do you mean? Is it waiting before it rotates some of them?

No, no waiting at all what you code is doing is that your looping through all the attachments inside of the AttachmentContainer and your rotating each of them by 90, which isn’t rotating them as one single unit

To my knowledge, rotating each attachment as a group isn’t exactly possible. It could be, but I’ve never quite seen a request like this. You’d have to either use a for loop, rotate the part itself, or create individual parts in replacement of those attachments.

But isnt there some fancy cframe inverse math I can do?

I’m not sure. I can’t help you any further than this. I’m sorry. :frowning:

Think about a 3 x 3 matrix that is unrotated that would look like this

No Rotation Matrix
matrix not rotated

Rotated Matrix
ROTATED MATRIX

This is baiscally what i’m trying to do with the attachments

You can try setting the PrimaryPart of the model as the background of the “matrix”, and so when you try and move it, you can just address the model in the script and use PivotTo()

Basically your script should look something like this

workspace.yourmodel:PivotTo(CFrame.fromEulerAnglesXYZ(x number when oriented, y when oriented, z when oriented))

Try this?

local function rotateAttachment(attachment: Attachment, angle: number, pivot: Vector3)
	local rotatedPosition = CFrame.Angles(0, math.rad(angle), 0) + pivot

	attachment.CFrame = CFrame.new(rotatedPosition.Position, pivot)
end