How do I make different oriented parts face the same way?

  1. What do you want to achieve? I want to position 2 parts that are different in the same way.

  2. What is the issue? Since the parts orientations are different I can’t just do Part.Orientation = Vector3.new(0, 90, 0)

  3. What solutions have you tried so far? I tried to check if the part was facing away and then turn it accordingly but I failed

For example, If I rotate set both part’s orientation to 90

This happens:

Since the sword is already facing up the sword faces to the right but the boombox faces correctly.

How can I fix this?

Edit : I couldn’t represent how the boombox would look like actually but I think you get it.

Just set orientation for both parts individually. By that I mean find the right angle for each part and set it to that angle. Example (with cframe):

part1.CFrame = part1.CFrame * CFrame.fromEulerAnglesYXZ(0, math.rad(90), 0)
part2.CFrame = part2.CFrame * CFrame.fromEulerAnglesYXZ(0, math.rad(180), 0)
local Game = game
local ReplicatedStorage = Game:GetService("ReplicatedStorage")
local Script = script
local ScreenGui = Script.Parent

for Index, Child in ipairs(ReplicatedStorage:GetChildren()) do
	if Child:IsA("Tool") then
		local Handle = Child:FindFirstChild("Handle")
		if not Handle then continue end
		local ViewportFrame = Instance.new("ViewportFrame")
		ViewportFrame.Position = UDim2.new(0, (Index - 1) * 100, 0, 0)
		ViewportFrame.Size = UDim2.new(0, 100, 0, 100)
		local Clone = Child:Clone()
		local X, Y, Z = Handle.Size.X, Handle.Size.Y, Handle.Size.Z
		local Max = math.max(X, Y, Z)
		Clone.Handle:PivotTo(CFrame.new(0, 0, -Max) * CFrame.fromOrientation(if Z == Max then -math.pi / 2 else 0, math.pi, 0))
		Clone.Parent = ViewportFrame
		ViewportFrame.Parent = ScreenGui
	end
end

GearDisplay.rbxl (38.8 KB)
image

Let me know if this needs to accommodate other gears.

1 Like