✓ Accepted answer
Unfortunately you can't achieve rotation with TweenService easily. Tweens will always choose shortest "path" to their goal. Half turn is the best you can get, but you also have no control over the direction of spin.
To solve this you need to do some shenanigans. I, for example, create three tweens, each making one third of a turn. Two tweens are not enough, and usually result in part "swinging" forward and back. This way you "force" tween to make a full 360 degree turn.
local TweenService = game:GetService("TweenService")
local PartProperties1 = {CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(120),0) }
local PartProperties2 = {CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(240),0) }
local PartProperties3 = {CFrame = script.Parent.CFrame}
local TweenInfov = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Tween1 = TweenService:Create(script.Parent,TweenInfov,PartProperties1)
local Tween2 = TweenService:Create(script.Parent,TweenInfov,PartProperties2)
local Tween3 = TweenService:Create(script.Parent,TweenInfov,PartProperties3)
Tween1.Completed:Connect(function() Tween2:Play() end)
Tween2.Completed:Connect(function() Tween3:Play() end)
Tween3.Completed:Connect(function() Tween1:Play() end)
Tween1:Play()
Swap tweens around, to change direction of the spin. I hope this helps!
p.s. As a side note, to stop the spin you will need to disconnect those connections. For example:
local con1 = Tween1.Completed:Connect(function() Tween2:Play() end)
local con2 = Tween2.Completed:Connect(function() Tween3:Play() end)
local con3 = Tween3.Completed:Connect(function() Tween1:Play() end)
Tween1:Play()
wait(10) - let it spin
con1:Disconnect()
con2:Disconnect()
con3:Disconnect()
Edit: Added missing brackets
1 comment
Thank you, my game is one step closer to finished ;) , also, to anyone else reading this, add wait(0.2) at the start if you plan on using the script on a part from replicated storage, else it will glide to the position of the original part