How to put one part on another?

so I have built a script that welds parts and turns them into a tool etc..
Pretty much building a tool with two parts but in a way where it can be any sized parts.

My problem is:
I have no idea how to make the two parts stack on top of each other and not be colliding.

I have looked far and wide for the answer yet found nothing,
I have tried hundreds of ways yet no result.

Does anyone know how to do this or
anywhere I should look for the answer?

Thanks!

More info just in case:
Parts are either unioned or just a normal part.

Parts can be any size.

The closest I have gotten was going based off size of a model then moving said part
equally, but the parts always end up floating above or inside the other part.

This only needs to move one part Labeled “T” in the script above another part Labeled “H” which is below “T”

Here is the piece of the code that i’m trying to get working no matter the parts height:
T.Position = H.Position + Vector3.new(0,1,0)

2 Likes

Do you think you could provide more detail to what problems you are facing? If you can, please provide a video.

What info would be more useful?

The code that you are running, and a video of the code running.

well the code has varied depending on what I was trying but I can still provide some

T.Position = H.Position + Vector3.new(0,H.Size.Y,0)

To do this, set T’s position using both the part’s sizes, specifically their height.

T.Position = H.Position + Vector3.new(0, H.Size.Y / 2 + T.Size.Y / 2, 0)

This should stack the parts perfectly. If they also have rotation, consider using CFrames so this works at all angles.

T.CFrame = H.CFrame * CFrame.new(0, H.Size.Y / 2 + T.Size.Y / 2, 0)

Let me know if you have any questions about how this works!

4 Likes

THANK YOU (I am terrible at math so I wouldn’t of ever thought of this)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.