Need help on attachment positions

I’m trying to make it so that the position of the attachment depends on the amount of attachments connected to the HumanoidRootPart.

Because with the two attachments they’re both equidistant from the center but with the three attachments there’s one attachment in the middle and I have no idea what I’m doing :confused:

1 Like
	X Positions
	
	1Att =  0
	2Att = -1, 1
	3Att = -2, 0, 2
	4Att = -3, -1, 1, 3
	5Att = -4, -2, 0, 2, 4

it seems like there should be a way to do this

This code should give you the desired results:

local DISTANCE = 2

local Max = NumAttachments - 1
local Positions = {}

if Max == 0 then
    table.insert(Positions, 0)
else
    for Attachment = -Max, Max, DISTANCE do
        table.insert(Positions, Attachment)
    end
end

It’s mainly just finding a pattern and turning it into code.

3 Likes

is this the same thing?

for i = -num + 1, num - 1, 2 do
	Attachments[i].Position = Vector3.new(i, 2, -3)
end
1 Like

Yep.

Oh, thank you so much, Emerald.

2 Likes