The problem is that the part’s center is welded to the other part and not the surface.
I want that so the surface of those parts weld together while keeping the orientation of the part. Like this:
In this case you should change the C0 to make it say on the side.
local face = Enum.NormalId.Top -- change to make it stay on a different side
local faceVec = Vector3.FromNormalId(face)
local part0 = workspace.Part0
local part1 = workspace.Part1
local weld = Instance.new("Weld")
weld.C0 = CFrame.new((faceVec*(part0.Size/2))+(faceVec*(part1.Size/2)))
weld.Part0 = part0
weld.Part1 = part1
weld.Parent = part0
But what if the orientation is different? Because in my game players have the ability to rotate parts however they like, so how can I get the correct numbers using the orientation? Or is it just not possible?
To be honest I am fine with part going little bit inside.