Cant Spin a part in a X-axis only

The problem:

What i want:

Code/Script
for _, spinningPart: BasePart in pairs(CollectionService:GetTagged("SP_KB")) do
	task.spawn(function()
		while true do
			for i = 0, 360, 1.5 do
				local NewCFrame = CFrame.new(spinningPart.Position) * CFrame.Angles(math.rad(i)*-5, 0, 0)
				spinningPart.CFrame = NewCFrame
				task.wait()
			end
		end
	end)
end

There are a few issues here. All of them are related to this line:

local NewCFrame = CFrame.new(spinningPart.Position) * CFrame.Angles(math.rad(i)*-5, 0, 0)

First by pre-multiplying against CFrame.new(spinningPart.Position) you’re now rotating around the world aligned axes. You’ll want to pre-multiply against the inital cframe of the spinning part so you retain your intial orientation.

local initialCF = spinningPart.CFrame
while true do
	for i = 0, 360, 1.5 do
		local NewCFrame = initialCF * CFrame.Angles(math.rad(i)*-5, 0, 0)
		-- ...

Secondly, you’re rotating around the wrong axis. In the video where you’re demoing the behavior you want do you see how when you have the object selected there’s little “L” in the corner? This means the dragger is using the object’s local space. You can toggle between this and world space by pressing “Ctrl + L”.

When in local space mode you can use the colors of the handles to help you figure out which axis you want to rotate around. In your case you’re rotating around the green axis which represents the y-axis. So, your final code should be:

local NewCFrame = initialCF * CFrame.Angles(0, math.rad(i)*-5, 0)

yup, should be what egomoose said here. ive run into this issue so many times when i started using cframes for things since i didnt understand them, but basically, when you make a cframe, it thinks its position and rotation values are all zero unless you multiply the initial cframe by the new one.

so if you dont multiply the new cframe by the original one when attempting to mess around with positions and rotations, itll just force all of a parts position/rotation values to zero