My Part Placing Tool Rotation Is Broken?

This has genuinely stumped me for 2 days straight.

I made a tool for placing stuff right? I made a rotate (R) and twist (T) feature, it works fine. But there’s one problem I can’t manage to fix.

So basically, whenever you press R once, and T again, this happens right?
RobloxStudioBeta_1C5Kv0eTrQ

Then when I press R again, instead of going like this:
RobloxStudioBeta_bgCm7pbq6Y

It goes like this?
RobloxStudioBeta_tJ60jATWLp

This is the code that’s supposed to rotate the plank in that order:

--[[MY VARIABLES]]--
local partOrientations = {
	rot0 = CFrame.Angles(0,0,0),
	rot1 = CFrame.Angles(0,math.rad(90),0),
	rot2 = CFrame.Angles(math.rad(-90),0,0),
	rot3 = CFrame.Angles(0,math.rad(90),math.rad(-90)),
	rot4 = CFrame.Angles(0,math.rad(180),math.rad(-90)),
	rot5 = CFrame.Angles(math.rad(-90),math.rad(-90),0)
}

--[[CODE SOMEWHERE INSIDE A INPUTBEGAN FUNCTION]]--
elseif currentPartOrientation == partOrientations.rot2 then
			if rotationDebugging == true then
				print("rot2 > rot5")
			end
			currentPartOrientation = partOrientations.rot5
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot5 then
			if rotationDebugging == true then
				print("rot5 > rot2")
			end
			currentPartOrientation = partOrientations.rot2
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation

Whenever I rotate it, it’s supposed to switch from rot2 (-90,0,0) to rot5 (-90,90,0) right?
Instead, it switches the orientation from (-90,0,0) to (0,90,-90)??
RobloxStudioBeta_2vEYKAIHQn

It prints out “rot2 > rot5” so it isn’t firing anything else… Why is this happening?


HERES THE ENTIRE CODE
local playersService = game:GetService("Players")
local debrisService = game:GetService("Debris")
local replicatedStorageService = game:GetService("ReplicatedStorage")
local placementEvent = replicatedStorageService.Events.Collectibles.PlacementEvent
local woodTarget = replicatedStorageService.Models.CollectiblePreset.WoodTarget
local userInputService = game:GetService("UserInputService")
local getMouse = playersService.LocalPlayer:GetMouse()
local getTool = script.Parent
local getPlayer = workspace:WaitForChild(playersService.LocalPlayer.Name)
local toolDebounce = false
local partInstance
local partOrientations = {
	rot0 = CFrame.Angles(0,0,0),
	rot1 = CFrame.Angles(0,math.rad(90),0),
	rot2 = CFrame.Angles(math.rad(-90),0,0),
	rot3 = CFrame.Angles(0,math.rad(90),math.rad(-90)),
	rot4 = CFrame.Angles(0,math.rad(180),math.rad(-90)),
	rot5 = CFrame.Angles(math.rad(-90),math.rad(90),0)
}
local currentPartOrientation = partOrientations.rot0
local rotationDebugging = true

userInputService.InputBegan:Connect(function(getInput)
	if getInput.KeyCode == Enum.KeyCode.R then
		if currentPartOrientation == partOrientations.rot0 then
			if rotationDebugging == true then
				print("rot0 > rot1")
			end
			currentPartOrientation = partOrientations.rot1
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot1 then
			if rotationDebugging == true then
				print("rot1 > rot0")
			end
			currentPartOrientation = partOrientations.rot0
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation

		elseif currentPartOrientation == partOrientations.rot3 then
			if rotationDebugging == true then
				print("rot3 > rot4")
			end
			currentPartOrientation = partOrientations.rot4
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot4 then
			if rotationDebugging == true then
				print("rot4 > rot3")
			end
			currentPartOrientation = partOrientations.rot3
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation

		elseif currentPartOrientation == partOrientations.rot2 then
			if rotationDebugging == true then
				print("rot2 > rot5")
			end
			currentPartOrientation = partOrientations.rot5
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot5 then
			if rotationDebugging == true then
				print("rot5 > rot2")
			end
			currentPartOrientation = partOrientations.rot2
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		end
		--[[KEYCODE T]]
	elseif getInput.KeyCode == Enum.KeyCode.T then
		if currentPartOrientation == partOrientations.rot0 then
			if rotationDebugging == true then
				print("rot0 > rot2")
			end
			currentPartOrientation = partOrientations.rot2
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot2 then
			if rotationDebugging == true then
				print("rot2 > rot0")
			end
			currentPartOrientation = partOrientations.rot0
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation

		elseif currentPartOrientation == partOrientations.rot1 then
			if rotationDebugging == true then
				print("rot1 > rot3")
			end
			currentPartOrientation = partOrientations.rot3
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		elseif currentPartOrientation == partOrientations.rot3 then
			if rotationDebugging == true then
				print("rot3 > rot1")
			end
			currentPartOrientation = partOrientations.rot1
			partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
		end
	end
end)

getTool.Equipped:Connect(function()
	for i,v in ipairs(workspace.Running:GetChildren()) do
		if v:IsA("Part") and v.Name == "WoodTarget" then
			v:Destroy()
		end
	end
	
	partInstance = woodTarget:Clone()
	partInstance.Name = "WoodTarget"
	partInstance.Transparency = .8
	partInstance.Size = Vector3.new(8.614, 1, 18.417)
	partInstance.BrickColor = BrickColor.new("Lime green")
	partInstance.Parent = workspace.Running
	partInstance.Anchored = true
	partInstance.CanCollide = false
	partInstance.CanTouch = false
	partInstance.CanQuery = false
	
	getMouse.TargetFilter = partInstance
	
	getMouse.Move:Connect(function()
		partInstance.CFrame = CFrame.new(getMouse.Hit.p) * currentPartOrientation
	end)
end)

getTool.Unequipped:Connect(function()
	debrisService:AddItem(partInstance, .001)
end)

getTool.Activated:Connect(function()
	if toolDebounce == false then
		toolDebounce = true
		placementEvent:FireServer(CFrame.new(getMouse.Hit.p) * currentPartOrientation, "Wood")
		task.wait(.1)
		toolDebounce = false
	end
end)

if getPlayer then
	getPlayer.Humanoid.Died:Connect(function()
		if partInstance then
			debrisService:AddItem(partInstance, .001)
			script:Destroy()
		end
	end)
else
	error("PLAYER CANNOT BE FOUND!")
end

HERES ALSO THE GAME: Anvil Test [v3.0] - Roblox

What does this mean?

RTTR, or RTR?

EDIT: Oh, and you could simplify your code a lot of you just make R and T rotate 90 degrees on different axes. Is there a reason that you’ve got that specific rotation pattern?

R and T means like I’m pressing those keys in the keyboard.

I mean, I am technically adding 90 degrees right? I just did it in a different way. I can’t really change or touch the code cuz I’m on vacation. Typing on a phone is so painful.

(Do you know why it’s switching from (90,0,0) to (0,90,-90), even though rot5 variable isn’t (0,90,-90)?)