How to make a part rotate a full circle with CFRAME and TWEENSERVICE

As of right now if I wanted to spin a part in a full circle using orientation, I can do this

local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local goal = {Orientation = Vector3.new(0,360,0)}
local tween = game:GetService("TweenService"):Create(script.Parent, info, goal)
tween:Play()

However for my current thing I’m working on I need to use CFrame (because I’m working with welds) and I can’t figure out a way to do the same thing, please help!

FYI : I DO NOT want to use more than one tween, otherwise I won’t be able to control the easing style smoothly

1 Like
local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local goal = {CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(360),0)}
local tween = game:GetService("TweenService"):Create(script.Parent, info, goal)
tween:Play()

I don’t know if this is what you want, but this is a CFrame variant of orienting.

1 Like

you can easily use multiple tweens whilst being in control of the easing style. you just have to do a loop and or a task.wait() the amount of time of the tween so it seamlessly moves it.

1 Like

that rotates the CFrame by 0 degrees, I’ve already tried it

1 Like

I don’t want to use multiple tweens because let’s say I want to use the easing style Sine with direction InOut, I won’t perfectly get the same exact style pattern if I had to distribute the rotation into multiple tweens

I also definitely don’t feel like manually tweaking the time and style of each tween just to replicate the original style that I could just use one tween and avoid the hassle

1 Like

to my knowledge its impossible to do without multiple tweens as changing something by more than 180 degrees will just make it move less to get to that position as if you asked it to move by <180 in the opposite direction, if u rotate by 360 it won’t move at all as its essentially the same position.

1 Like

Are you positive you can’t just use Lerp and TweenService:GetValue() as an alpha? It’s easier to do this via just making your own interpolation function rather than using TweenService.

I ended up creating a number Value instance called SpinOrientation and tweened the value instead of tweening the CFrame

local part = script.Parent
local SpinOrientation = part.SpinOrientation

SpinOrientation.Changed:Connect(function(num)
    part.CFrame = CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(num),0)
end)

while true do
    SpinOrientation.Value = 0 — reset the value so it doesn’t go to infinity

    local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
    local goal = {Value = SpinOrientation.Value + 360}
    local tween = game:GetService("TweenService"):Create(SpinOrientation, info, goal)
    tween:Play()
    task.wait(2.5)
end
7 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.