Weld two faces together?

I have two parts:

Image

I weld them together using a script:

Image

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:

Image

How can I do this?
Here is my weld script:

local part0 = workspace.Part0

local part1 = workspace.Part1

local weld = Instance.new("Weld")

weld.Part0 = part0

weld.Part1 = part1

weld.Parent = part0

Any help is appreciated!

Probably using something like weld.C0 = CFrame.new(0, 0, 0) * CFrame.new(0,0,0)
*Changing the values to what fits your taste?
Hope this helps.

weld.C0 = CFrame.new(0, 0, 0) * CFrame.new(0,0,0)

I know its something like that, but the real question is:
What will replace the 0,0,0?

That is what I am trying to figure out.

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
1 Like

How can I also keep the orientation?
Something like this?

Image

Or is it not possible?

Probably by adding an extra Vector and multiplying the CFrame to get a rotation.

local face = Enum.NormalId.Front
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))+Vector3.new(0,0,-0.08))*CFrame.Angles(math.pi/4,0,0)
weld.Part0 = part0
weld.Part1 = part1
weld.Parent = part0

You will probably need to change the vector that is added and the angle.

Result

image

For me it is a little bit inside the part:

Image

Script:

local face = Enum.NormalId.Top

local faceVec = Vector3.FromNormalId(face)

local part0 = workspace.Part0

local part1 = workspace.Part1

local weld = Instance.new("Weld")

weld.Part0 = part0

weld.Part1 = part1

weld.C0 = CFrame.new((faceVec * (part0.Size/2))+(faceVec * (part1.Size / 2))+Vector3.new(0,0,0))*CFrame.Angles(0,0,math.rad(-39.07))

weld.Parent = part0

Try changing the numbers in this so it won’t go in the part.

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.