Options:
- Use
wait(), which will wait for approximately 0.03 seconds (this will update 3x more frequently than what you are currently doing)
- Use RunService's events/functions to update the animation. This is up to 2x better than the previous option, but it's sometimes harder to script (specifically to start and stop it when you want) and isn't that noticeable. ex:
game:GetService("RunService").Heartbeat:Connect(function(step)
object.CFrame = object.CFrame * CFrame.Angles(0.02,0,0)
end)
You can also improve the animation quality by doing rotation based on the amount of time that has elapsed. ex, wait() actually returns this, and you can use the step argument for the same purpose. ex, instead of doing * CFrame.Angles(0.02, 0, 0), you might just do * CFrame.Angles(step, 0, 0). This way, if the game slows down or lags, the animation will still continue at the same speed (though obviously choppier).
[Edit: greatneil80 is right, you can also use the TweenService to rotate, though you'd have to update it pretty much every frame if you wanted something to rotate indefinitely. Still, you could combine it with the wait() for loop if you wanted to avoid using the RunService.]
1 comment
I know there is a tween for objects and Vector3.new