Cant get the rotation that i want

So i have this game where i can grab object and then rotate them “Q” for x axis and “E” for y axis.

UserInputService.InputBegan:Connect(function(input, processed)
	if input.KeyCode == Enum.KeyCode.Q and canRotate then
		rotationX += 90
		if rotationX == 360 then
			rotationX = 0
		end
		return
	end
	
	if input.KeyCode == Enum.KeyCode.E and canRotate then
		rotationY += 90
		if rotationY == 360 then
			rotationY = 0
		end
		return
	end
end)

then i have a runService that updates an attachments position

local targetCFrame = -- just an offset from the character
dragAttachment.WorldCFrame = targetCFrame * CFrame.Angles(math.rad(rotationX), math.rad(rotationY), 0)

And then i use an allignOrientation and an allignPosition so that objects i grab follow the attachment but it doesnt rotate the way i want to.

when i rotate Y i always want it to rotate sideways as shown in the video. When i rotate X it always rotates upwards like i want no matter the current rotation. But the way it rotates on the Y axis changes depending on the X rotation.

What can i do?

You’ll need to adjust the Z rotation whenever the player tries to modify the X rotation while the bike is flipped.

brooo ty, i was so sure i tried that but now i realised i did it wrong. thanks

No problem, if you need any extra help feel free to ask.