Cframe.Angles is not rotating correctly

You can write your topic however you want, but you need to answer these questions:

My Cframe.Angles is not rotating to the proper degree, it’s either too little off, or too far off

I’ve already tried using fromeuleranglesXYZ and putting angles as a seperate PivotTo() Line but none of them have worked, only causing further issues

I’m trying to get the levels to line up, in whatever orientation the red brick is in
THE GREEN BRICK IS SUPPOSED TO LINE UP WITH THE RED BRICK!

local Random1 = math.random(1,4)

	if Random1 == 1 then

		local CloneRoom1 = game.ReplicatedStorage.RoomGenerationPieces.Room1:Clone()
		CloneRoom1.Parent = Room1

		for i,v in pairs(Room2:GetChildren()) do
			
			CloneRoom1:PivotTo(CFrame.new(v.End.Position) * CFrame.Angles(v.End.Orientation.X,v.End.Orientation.Y,v.End.Orientation.Z))

		end

	end
	
	if Random1 == 2 then

		local CloneHidingRoom1 = game.ReplicatedStorage.RoomGenerationPieces.HidingRoom1:Clone()
		CloneHidingRoom1.Parent = Room1

		for i,v in pairs(Room2:GetChildren()) do
			
			CloneHidingRoom1:PivotTo(CFrame.new(v.End.Position) * CFrame.Angles(v.End.Orientation.X,v.End.Orientation.Y,v.End.Orientation.Z))

		end

	end
	
	if Random1 == 3 then

		local Room1Left = game.ReplicatedStorage.RoomGenerationPieces.Room1Left:Clone()
		Room1Left.Parent = Room1

		for i,v in pairs(Room2:GetChildren()) do
			
			Room1Left:PivotTo(CFrame.new(v.End.Position) * CFrame.Angles(v.End.Orientation.X,v.End.Orientation.Y,v.End.Orientation.Z))

		end

	end
	
	if Random1 == 4 then

		local Room1Right = game.ReplicatedStorage.RoomGenerationPieces.Room1Right:Clone()
		Room1Right.Parent = Room1

		for i,v in pairs(Room2:GetChildren()) do
			
			Room1Right:PivotTo(CFrame.new(v.End.Position) * CFrame.Angles(v.End.Orientation.X,v.End.Orientation.Y,v.End.Orientation.Z))

		end

	end


Idk if this is the problem, but have you tried converting the arguments to CFrame.Angles into radians with math.rad()?. Because roblox studio is stubborn that way with radians and degrees ¯_(ツ)_/¯

Orientation is in degrees and the angles are applied in YXZ order. So if you want to use it to create a CFrame, you should convert the angles to radians and use CFrame.fromEulerAnglesYXZ, CFrame.fromEulerAngles with angle applying order parameter or CFrame.fromOrientation.

However, in this case, I think you could just replace

CFrame.new(v.End.Position) * CFrame.Angles(v.End.Orientation.X,v.End.Orientation.Y,v.End.Orientation.Z)

with

v.End.CFrame

Thank you for the help! The person below also helped!

Thank you for the help RoBo! This is the other solution I found out worked!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.