The problem is that you are randomly rotating the part by a very large amount (1 radian is almost 57.3 degrees). Therefore you could generate a rotation very far from the current one, making it jump really quickly.
But even if you make this value smaller it will give a shaking and not very smooth effect. The best thing to do would be to interpolate between the old and new rotations. Luckily, this is quite easy using delta time and the CFrame lerp function:
local part = script.Parent
local duration = 1
local function rand()
return math.random()*2*math.pi - math.pi
end
while true do
local firstTick = tick()
local start = part.CFrame
local goal = start * CFrame.Angles(rand(), rand(), rand())
repeat
local elapsed = tick() - firstTick
local alpha = math.min(1, elapsed/duration)
part.CFrame = start:lerp(goal, alpha)
wait()
until alpha == 1
end
1 comment
Try just math.random