Attachment's position completely off

I’m trying to position attachments around the HumanoidRootPart but I ran into a problem. Here is a simplified version of the code:

local point = Instance.new("Attachment")
point.Name = "Point"
point.WorldPosition = character.HumanoidRootPart.Position
point.Parent = character.HumanoidRootPart

This isn’t exactly what I’m doing but it goes to show that even setting the Attachment’s position to a static part is completely off. The position just goes super far away. I also did it with just normal parts and the same thing happened. I’ve also tried the Position, CFrame, and WorldCFrame properties.

Image:
image

Thanks!

4 Likes

I don’t see the point of setting it’s WorldPosition to the HRP if you’re parenting it to the HRP on the next line, when you parent the attachment to the HRP it will automatically put the attachment directly inside of the HRP.

Because when you set an Attachment’s Position with a script it is in relation to the Part the Attachment is in. If you set it to 0,0,0 then the Attachment will be at the center of the HumanoidRootPart.
0,2,0 will be 2 studs above the center of the HumanoidRootPart.

WorldPosition sets it relative to the world and not the part so I’m not sure why it sets it far away.

It was just to get the point across and to show it setting it far away. The actual script is different.

The world position for new attachments is automatically set to the world position of the parent when it gets parented

Yea that’s what I’m confused about, it sets it far away for.

Don’t set it in WorldPosition.
That’s fine if you’re fine tuning an Attachment that’s already in a Part to align it with another Attachment. If you are setting it with a script just set its Position in relation to its Parent.

I actually figured it out. I set the WorldPosition after setting the parent, and it worked. Plus, I couldn’t have done it this way because I had a script that generated points and it would be difficult to make all the points relative.

1 Like