How do i put a part on top on another part if the another part is rotated?

i am trying to make a tree growing system kinda like in lumber tycoon 2, but the problem is when a new segment appear (or new branch) instead of being on top of the first segment it appears on top of the first segments hitbox.

if you dont understand what im trying to say heres a screenshot:


and here is my current method of placing a part on top of another part:
galaz.Position = poprzedniaGalaz.Position + Vector3.new(0,poprzedniaGalaz.Size.Y/2,0)
galaz is the new segment/branch and poprzedniaGalaz is previous segment (the one new branch is being placed on)

1 Like

You can use CFrame’s to make the position relative to the base of the tree. This should move the Galaz half its Y size up depending on the way it’s pointing.

local moveUp = Vector3.new(0,poprzedniaGalaz.Size.Y/2,0)
galaz.CFrame = poprzedniaGalaz.CFrame * CFrame.new(moveUp)

yeah its working, thanks a lot!