Personally, I am a huge fan of using motor6d, which is basically a cframe motor. There’s several plugins which can assist you in this creation of these, I suggest looking into it.
There are multiple ways of doing this as @SalientViper says with Motor6D, but also with TweenService, given the location by CFrame. However, if you want the player to stand on the spinning part without falling off, I wouldn’t recommend using TweenService.
Depends what their use case is. I think the easiest thing is to make no assumptions until the original poster says the use case. Or state all assumptions alongside your solution.
A situation-specific assumption without limitations and assumptions stated next to it can lead beginners down the wrong path easily.
The spinning object may need to interact with server-owned physical objects as well as the character and client-owned objects. I’ll wait to see if @Soggy_Bomb has any specific use case and scenarios that it needs to cover.
local part = script.Parent -- the part
local partspeed = 0.05 -- speed of the spin
while task.wait() do
part.CFrame = part.CFrame * CFrame.Angles(0,partspeed,0) -- the spin of the part
end
reduce the increment it rotates by and the wait time by the same factor e.g if your doing wait(21) and rotate by 7 degrees each loop, reduce it to rotate by 1 and wait 3. or you could use the TWEEN service or the lerp service which is used for smooth movements
Using hingeconstraints you can make it spin very fast smoothly, reaching very high rpms, no scripting required. Torque, rate of accele/deceleration are all controllable right in the same window. With hingeconstraints you can also make it a servo type of motor which will automatically align a part with a certain orientation. Or you could just use it as a hinge where it spins freely along the axis it is attached to. hope this helped. hingeconstraints work much better than scripting, and you can actually use parts attached to hingeconstraints in the physics system, vs cframe scripting which does not actually change the velocity of the part and thus it can not correctly interact with other parts
You could probably Tween it to rotate 90 degrees and keep playing the Tween infinitely.
Here is an example:
local TweenService = game:GetService("TweenService")
local Part = game.Workspace.Part
local Info = TweenInfo.New(
1,
enum.EasingStyle.Sine,
enum.EasingDirection.Out,
math.Huge -- This Loops it over and over
false,
0
)
local Goal = {
CFrame = Part.CFrame * CFrame.Angles(0, math.rad(90), 0)
}
local Tween = TweenService:Create(Part, Info, Goal)
Tween:Play()