Just to make it clear what I mean: I do NOT mean CFrame = part.CFrame * CFrame.Angles
Imagine a part is already moving/being tweened, is there a way to make a 2nd tween that changes purely the part’s orientation through cframes without changing the position or am I forced to tween purely the orientation without cframes? Because if you try to tween with CFrame =part.CFrame * CFrame.Angles while the part is moving then it’ll constantly try to stick to one position and it starts glitching out
local position = part.Position
local targetRotation = CFrame.Angles(math.rad(x), math.rad(y), math.rad(z))
local goalCFrame = CFrame.new(position) * targetRotation
ok sorry i didn’t read past the title. but you can’t really do what you’re describing with tweens. you’re going to have to use a heartbeat loop or a while loop to update the cframe
Sorry for the long wait!! I had to do some testing with this. Here’s how you can pull it off:
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local part = [yourPart]
local tweenConnection : RBXScriptConnection = nil
-- create the values --
local rotationValue = Instance.new("CFrameValue"); rotationValue.Parent = script
local x, y, z = part.CFrame:ToOrientation(); rotationValue.Value = CFrame.Angles(x, y, z)
-- pretty self explanatory, set the value to the current orientation
local positionValue = Instance.new("Vector3Value"); positionValue.Parent = script
positionValue.Value = part.Position
-- also pretty self explanatory, set the value to the current position
-- our goals --
local goalPosition = [yourGoalPosition]
local goalRotation = CFrame.Angles(0, math.rad(90), 0)
-- tweens --
local positionTween = TweenService:Create(
positionValue,
TweenInfo.new(10),
{Value = goalPosition}
)
local rotationTween = TweenService:Create(
rotationValue,
TweenInfo.new(5),
{Value = goalRotation}
)
positionTween:Play()
tweenConnection = RunService.Heartbeat:Connect(function()
part.CFrame = CFrame.new(positionValue.Value) * rotationValue.Value
end)
-- here we set up a connection that will constantly calculate our orientation & position
-- each heartbeat, preventing tween overlap which was your issue.
-- because [rotationValue.Value] is the part's current rotation at the time
-- of setting this up there's no jarring changes to the part's orientation.
task.wait(5)
rotationTween:Play()
positionTween.Completed:Once(function()
if tweenConnection.Connected then
tweenConnection:Disconnect()
end
tweenConnection = nil
end)
-- we stop listening for RunService.HeartBeat because the tween has ended.
This method supports EasingStyle and EasingDirection as well! Hope this works for you.