Copy one value of orientation to another part!

Is there a better way to copy one value of orientation from part1 to part2?
At the moment i do it like this:

local part1 = script.Parent.Part1
local part2 = script.Parent.Part2

part1:GetPropertyChangedSignal("Orientation"):Connect(function()
	part1 = script.Parent.Part1
	part2 = script.Parent.Part2
    part2.Orientation = Vector3.new(part2.Orientation.X, part1.Orientation.Y, part2.Orientation.Z)
end)

You could do:

part2.Orientation = part2.Orientation * Vector3.new(1, 0, 1) + part1.Orientation * Vector3.yAxis

This will get the X & Z component off of part2.Orientation while getting only the Y component of part1.Orientation

yea

local part1 = workspace.Part1
local part2 = workspace.Part2

part1:GetPropertyChangedSignal("Orientation"):Connect(function()
	part2.Orientation = part1.Orientation
end)

I don’t think this would give the desired effect, since:

Gets uses the original X, Z rotation and only copies the Y rotation.

However, @Siggi_Suffkopp, I think you might want to take a look at AlignOrientation (roblox.com). I haven’t experimented with it while AlignPosition.PrimaryAxisOnly == true, but it looks like that would allow you to copy only the Y rotation of the other part, without the need for a script. Don’t forget to set AlignPosition.Responsiveness = 200 if you want it to be an instant rotation, instead of a smooth one.

1 Like

Thanks, but that’s not what I’m looking for.
Imagine the following: a character is moved by MoveTo(part) to this part. Now HumanoidRootPart should have exactly the same value on the Y-axis (look at the part!). CFrame.new(HRP.Position, Part.Position) is not suitable, because then the LookVector points upwards if the part is higher than the character. My code works so far, I just wonder if there is a better way to do this.

My first reply is the same as your current code, just written in a different way. It doesn’t really make anything switching to that approach, so I would probably just keep it as it is now.

Also, you can still use CFrames:

CFrame.new(HRP.Position, Part.Position * Vector3.new(1, 0, 1) + Vector3.yAxis * HRP.Position.Y)
-- Which is the same as:
CFrame.new(HRP.Position, Vector3.new(Part.Position.X, HRP.Position.Y, Part.Position.Z)

By setting the Y value to be the same as the current Y value we avoid the issue of it point upwards.