Cannot set part X Orientation to 180 or -180

UPDATE: i ended up adding a Vector3 value inside the X parts I wanted to move then editing this value and setting part X orientation from that value(Vector3Value Value does not change after you set it)

I think this post belongs in #platform-feedback:engine-bugs but I don’t have permission to upload there

Apparently I’m not able to set a parts X Orientation to 180 or -180 as shown in the video below

even tho for Y and Z axis this works fine

this cause my main script to break cause of the math inside it

--this function works fine for when i have to rotate Y or Z axis if i try it on X tho it just glitch and break
function CubeControl:RotateSide(side, direction)
	side = string.lower(side)
	if side == "bottom" then side = "down" end
	side = string.upper(string.sub(side, 1, 1)) .. string.sub(side, 2, string.len(side))
	CubeControl:GetSides()
	CubeControl:WeldSide(side)
	local Debounce = true
	local Middle
	local Letter = string.upper(string.sub(side, 1, 1))
	for i, Part in pairs(Sides[side]) do
		if CubeControl:GetNumberAfterLetter(Part.Name, Letter) == 5 then
			Middle = Part
			break
		end
	end
	local Cordinate 
	if Letter == "L" or Letter == "R" then Cordinate = "X" elseif 
		Letter == "T" or Letter == "D" then Cordinate = "Y" elseif
		Letter == "F" or Letter == "B" then Cordinate = "Z"
	end
	local CurrentRotation = Middle.Orientation[Cordinate]
	local EndRotation
	if direction then
		EndRotation = CurrentRotation + 90
	else
		EndRotation = CurrentRotation - 90
	end
	local Loop
	Loop = RunService.Stepped:Connect(function()
		local Condition
		if direction then
			Condition = CurrentRotation < EndRotation
		else
			Condition = CurrentRotation > EndRotation
		end
		if Condition then
			if direction then
				CurrentRotation = CurrentRotation + 3
			else
				CurrentRotation = CurrentRotation - 3
			end
			local Vector
			if Cordinate == "X" then
				Vector = Vector3.new(CurrentRotation, Middle.Orientation.Y, Middle.Orientation.Z)
			elseif Cordinate == "Y" then
				Vector = Vector3.new(Middle.Orientation.X, CurrentRotation, Middle.Orientation.Z)
			elseif Cordinate == "Z" then
				Vector = Vector3.new(Middle.Orientation.X, Middle.Orientation.Y, CurrentRotation)
			end
			Middle.CFrame = CubeControl:ChangeRotation(Middle.Position, Vector)
		else
			Loop:Disconnect()
			CurrentRotation = EndRotation
			Debounce = false
		end
	end)
	repeat wait() until Debounce == false
	CubeControl:RenameSide(side, direction)
	CubeControl:DestroyJoints(Cube)
end

to reproduce this just insert a part to workspace and change the orientation to 180, 0, 0

I believe that this is expected behavior, because if you change the Y and Z to 180, 180, it results in the same orientation as if X was set to 180.
I recommend using CFrame.angles, though, because (I think) orientation is sorta like position in that if you change the orientation to be clipping with another part, it will snap to a nearest value.
CFrame.angles and the likes are kind of weird, don’t get me wrong, but they work way better from what I remember when I was trying to get orientation to work.
Below is an example of setting the rotation of a tree to be roughly straight up (-2, 2 degrees), but at a random rotation value. I used a model’s primary part since it was easiest with the model, but it would apply to normal parts, too.

tree:SetPrimaryPartCFrame(tree.PrimaryPart.CFrame:ToWorldSpace(CFrame.Angles(math.rad(math.random(-2,2)),math.rad(math.random(0,360)),math.rad(-90))))

This tutorial covers CFrames very well with tons of visual indicators, which really helped me to understand them better.

This is the code I use in my “minecraft-like” block placing tool. Feel free to use it how you’d like :slight_smile:
model:SetPrimaryPartCFrame(CFrame.new(position))
model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame:ToWorldSpace(CFrame.Angles(math.rad(tilt),math.rad(rotation),0)))

2 Likes