What I want is to constantly spin a part using TweenService. What happens with the code below is that when it finishes its 120 turn, it resets instead on continuing to rotate from where it is currently at.
I search the forum and found threads, but none actually worked for me.
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.In, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local spinTween = TweenService:Create(newBlackHole, tweenInfo, {CFrame = CFrame.new(newBlackHole.Position) * CFrame.fromEulerAnglesXYZ(0, math.rad(120), 0)})
spinTween:Play()
Honestly this issue comes up over and over on the forums and I have yet to see a decent way to constantly tween rotation.
I did it another way once, but that involved creating a old weld(deprecated weld) via script because they cannot be created in studio, then tweening the C1 property of the wel,d but that required extra parts because the part in question cannot be anchored to tween the weld!
Tween is used to provide smooth motion without binding anything to RenderStepped, if thats what your recommending.
This is exactly the sort of thing TweenService is for, so thats why I am trying to find someone who has done it. I use TweenService for all sorts of part animation tasks, but continuously rotating a part has proven very troublesome.
I dont want to use BodyMovers or Motor6d or bind anything to RenderStepped
You could attach a motor6d, animate with looping turned on, and then play it using a script, right? Or just use tween service for every 90*, 180*, 270* turn. I donât really understand using tweenservice for this.
well thanks anyway, but i said i didnt want to create a motor6d already. Creating animations and motor6d is really quite a lot of work and overhead for something so simple. Animations need to be uploaded to Roblox then downloaded to the game at runtime. This is really not ideal.
using TweenService is common practice to move and rotate parts. So the subject of the thread is what I am after, using Tweens to constantly spin a part.
Make sure that âreversesâ in the TweenInfo is false and ârepeatCountâ is 0 and âEasingStyleâ is âLinearâ.
Alternatively you might be able to set the Y rotation goal of the tween to math.huge, which will keep it running for a looooong time. Roblox usually maps the set value to 0-360 (or -180-180, not sure) internally anyways. Not sure if it works with tweening though.
local tweenService = game:GetService('TweenService')
local part = workspace.Part
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
while true do
local tween = TweenService:Create(part, tweenInfo, {CFrame = part.CFrame * CFrame.Angles(0,math.rad(90), 0)})
tween:Play()
tween.Completed:Wait()
end
The reason yours isnât working is because itâs just tweening to the same orientation over and over again which is why it looks like nothing is happening (result of setting RepeatCount to -1).
Alternatively you can rotate it by 120 degrees then once the tween completes add a Tween.Completed event. But it seems you are editing itâs Orientation properties so maybe just edit itâs orientation like this?
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.In, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local spinTween = TweenService:Create(newBlackHole, tweenInfo, {Orientation = newBlackHole.Orientation + Vector3.new(0, 360, 0)})
spinTween:Play()