Thing is spinning outta control

Not sure whats going on here but was switching code to use primary parts, as i wanna make this a npc

NextBot:SetPrimaryPartCFrame(NextBot:GetPrimaryPartCFrame() * CFrame.Angles(math.rad(0), math.rad((i)), math.rad(0)))
-- i goes up by 1 every loop

used this code and uh

remove the math.rad just use bare numbers CFrame.Angles(0,1,0)

Try this script instead. And dont use Set/GetPrimartPartCFrame it suffers with floating point drift and has been deprecated. Use GetPivot()/SetPivot()

local NextBot = script.Parent;
local cFrame =;
local rotateSpeed = 5;

	cFrame *= CFrame.fromAxisAngle(Vector3.yAxis,rotateSpeed*deltaTime);

Didnt know this, alright
Also, im pretty sure i messed up somewhere, as i dont understand it that great but i tried doing

Cf *= CFrame.fromAxisAngle(NextBot:GetPivot().Position.Y, 5*i)

And it errored with

The first argument to CFrame.fromAxisAngle() requires a vector3 (these are predefined in Vecto3.xAxis,Vector3.yAxis,Vector3.zAxis) depends on which axis you want to rotate over. To keep the original position change it to this:

local NextBot = script.Parent;
local cFrame =;
local Origin = NextBot:GetPivot().Position;

	cFrame *= CFrame.fromAxisAngle(Vector3.yAxis,2*deltaTime);
	NextBot:PivotTo(cFrame + Origin);

Got it to this

Cf *= CFrame.fromAxisAngle(Vector3.yAxis, 1*i)
NextBot:PivotTo(Cf + Origin)

While it does work
it still spins like hell

Not sure if this is just something that happens when rotating primary parts, but when i was using Cframe.Angles, it was working just fine with rotating one part

If you are increment i ever frame the speed of rotation is increasing. To make it slower just change it to 0.1 or something and lose the i.

Cf *= CFrame.fromAxisAngle(Vector3.yAxis, 0.1)
NextBot:PivotTo(Cf + Origin)

oh, weird
didnt do that before

Changed it to your method and it works :+1:
Thanks for the help and the extra information :smiley:

1 Like

No problem, glad you got it working. As a side note if you want to make sure the rotation is consistent for everyone (i.e. if this rotation is being run on the server). The deltaTime in my original version during Heartbeat will make sure that the rotation stays the same on all client.

1 Like