How can I achieve this?

The title is very bland because I don’t know how I would describe the issue in the title. I want to connect the front face of a part to the back face of a part while keeping the orientation of the parts the same. This might be a mouthful so this may help out:

I want to connect another parts front face to the back face of this part (highlighted in red) using a script. So afterward it would look something like this:

I want to do this because I want an easy way to set the orientation and placement of the arms on a viewmodel I am making. I’ve tried to use EgoMoose’s tutorial to help me figure this out but he is using a viewmodel with multiple parts for each arm. I am only using a single part for each arm and I have tried to tweak his code in an attempt to make it work to no success.

If anybody could help me that would be greatly appreciated!

1 Like

try this
part1 is the part you want to connect to the face of the other part
part 2 is the other part
part2.Orientation = part1.Orientation
part1.CFrame = part2.CFrame + part1.CFrame.LookVector +,part1.Size.X / 2,0)

This didn’t seem to do anything as seen in this video:

You can see the shadow of the viewmodel. Instead of the arms just being straight up I want them to be oriented towards the smaller parts. I’m completely stuck :confused: if you’re interested here is my localscript:

local camera = game.Workspace.CurrentCamera
local humanoid = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid")

local viewModel = game.ReplicatedStorage:WaitForChild("viewModel"):Clone()
viewModel.Parent = workspace

local function onDied()
	viewModel.Parent = nil

local function updateArm(key)
	local CurrentArm = viewModel[key.."Arm"]
	local CurrentArmAttachable = viewModel[CurrentArm.Name.."Attachment"]
	CurrentArm.Orientation = CurrentArmAttachable.Orientation
	CurrentArmAttachable.CFrame = CurrentArm.CFrame + CurrentArmAttachable.CFrame.LookVector +,CurrentArmAttachable.Size.X / 2,0)

local function onUpdate(dt)
	viewModel.Head.CFrame = camera.CFrame


I think theres this in built cframe function called ToWorldSpace() which does this