How do I make an attachment's orientation face a part?

local attachmentcharacter = Instance.new("Attachment",player.Character.HumanoidRootPart)
attachmentcharacter.Visible = false
attachmentcharacter.Position = (player.Character.HumanoidRootPart.CFrame * CFrame.new(GetPointOnCircle(7, 360/#player.PlayerPets.Equipped:GetChildren()*i))).p - Vector3.new(0,15,22)

So far i made the attachments spawn in a circle around the HumanoidRootPart.

How do I make the attachments look at the HumanoidRootPart ?

Does anyone know how to make this

I’m not sure that’s what you want to happen. You can do this by simply setting the WorldOrientation to

attachment.WorldOrientation = Vector3.new(CFrame.new(attachment.WorldPosition, otherPart.Position):ToEulerAnglesXYZ())

But I doubt that’s the effect you want - rotating an Attachment object.

image

I have the pets spawn in a circle around the player and I want them all to be facing the players Root part in the Y axis. There is an attachment inside the pet and one inside the humanoidrootpart and they both have the same position due to an AlignPosition. How do I make the parts orientated towards the players torso

1 Like

Have you tried his solution? It should thereotically work (even though setting the WorldCFrame is better: attachment.WorldCFrame = CFrame.new(attachment.Parent.Position, character.HumanoidRootPart.Position))

If it doesn’t work on its own, do that ^ and add AlignOrientations to the attachments as well.

local attachmentcharacter = Instance.new("Attachment",player.Character.HumanoidRootPart)
			attachmentcharacter.Visible = false
			attachmentcharacter.Position = (player.Character.HumanoidRootPart.CFrame * CFrame.new(GetPointOnCircle(7, 360/5*i))).p - Vector3.new(0,15,22)
			attachmentcharacter.WorldCFrame = CFrame.new(attachmentcharacter.Parent.Position, player.Character.HumanoidRootPart.Position)

			local attachmentpet = Instance.new("Attachment", clone.PrimaryPart)
			attachmentpet.Visible = false

			local alignposition = Instance.new("AlignPosition", clone)
			alignposition.MaxForce = 25000
			alignposition.Attachment0 = attachmentpet
			alignposition.Attachment1 = attachmentcharacter
			alignposition.Responsiveness = 25

			local alignorientation = Instance.new("AlignOrientation", clone)
			alignorientation.MaxTorque = 25000
			alignorientation.Attachment0 = attachmentpet
			alignorientation.Attachment1 = attachmentcharacter

This is what i wrote but the parts dont follow the player they just fall

I want the front face of each primarypart to face the players torso

attachmentcharacter.WorldOrientation = Vector3.new(CFrame.new(attachmentcharacter.Position, player.Character.HumanoidRootPart.Position):ToEulerAnglesXYZ())

tried it but it doesnt face

Still looking for a solution :slightly_smiling_face:

I have the same problem. I want an attachment to face the nearest part in a model to turn the car. I just want it to work on the Y axis.

It does face though, I just tested it.

If you still didn’t figure out then here is the solution, make another attachment and parent it to
the HumanoidRootPart (do not change the position of the attachment) then for your pet attachement do :

petattchment.CFrame = CFrame.new(petattachment.Position, theHRPAttachment.Position)
This worked for me

3 Likes