Maintaining an orientation for an attachment?

I want to make an attachment always face a certain orientation but when I tried this:

local currentvector = script.Parent.CFrame.UpVector * 5

while true do
wait()
script.Parent.Attachment.CFrame = script.Parent.Attachment.CFrame * CFrame.new(script.Parent.Position,currentvector)
end

the attachment flew in various directions.
how come this works for a normal part but not an attachment and what can I do to fix it?

I’m not exactly sure what you want to do, do you want like a part with an attachment always facing another attachment or the actual attachment rotating?

say the attachment now faces directly up, I want the attachment to then always face directly up even if the part its parented to rotates around.

its just like how a bodygyro faces a specific direction even if the part its parented to changes its position.

You can try this, not sure if it’ll work

local currentOrientation = attachment.WorldOrientation -- regardless of part rotation the WorldOrientation will be the same

while true do
   attachment.WorldOrientation = currentOrientation
   wait()
end
3 Likes

acually that works very well, thank you.

1 Like