How would I make it so when i rotate this wedge, it is on a specific world axis?

I’m trying to make this wedge rotate/change orientation specific to world axis, so when I do rotateY it will rotate the orientation on the y axis, but for some reason my script is rotating it super weirdly so if i rotate with RotateX, when I rotate with Y and Z it will change a different orientation axis than Y and Z(I don’t want this to happen)

video for reference

very bad image for reference
image

you can see that after I do rotate X, when i do RotateY again it changes a completely different orientation value than the Y one.

this is the code segment that moves and rotates the object to follow the mouse



local cframe = CFrame.New
local angles = CFrame.fromEulerAnglesFromXYZ
object:PivotTo(object.CFrame:Lerp(cframe(posX, posY, posZ)*angles(math.rad(rotationX), math.rad(rotationY), math.rad(rotationZ)), speed))

this is the code that changes the rotation when you press your rotate key

local rotationStep = 90
local rotationY = 0 --pressing r
local rotationZ = 0 --pressing t
local rotationX = 0 --pressing y

local function rotate(actionName, inputState, inputObj)
	if inputState ~= Enum.UserInputState.Begin then return end
	print(actionName)
	if actionName == "RotateY" then
		rotationY += rotationStep
	elseif actionName == "RotateZ" then
		rotationZ += rotationStep
	elseif actionName == "RotateX" then
		rotationX += rotationStep
	end
end

theres a ton more in the actual script i didnt put, and i merged in a few parts that arent in that part of the script simply for convenience, if you dont think i gave enough information feel free to ask.

I believe this is because orientation, the property your are looking it, rotates in Y X Z and not X Y Z
This is why when you rotate on the x, orientation shows the middle number as the number you rotated.

I don’t think so. Before rotating on X, Rotating on Y and Z works just fine and it rotates Y Z on the part. The order i put my variables in while defining them and the order inside the rotate function doesnt affect the actual rotation either.

You would have to change the pivot point of your wedge, I don’t know if there are APIs or not.