Can't run both tweens at the same time

Hello. I’ve been trying to make a simple script with two tweens which both update part’s CFrame.
But the problem is the first tween in order overrides the next CFrameTween so the second one just doesn’t run at all. I actually don’t know why this happens, because first updates the CFrame position while the second one updates CFrame rotation.

local TweenService = game:GetService("TweenService")
local TransparencyInfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local FallInfo1 = TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local FallInfo2 = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In)

local function fall()
	local part = script.Parent:GetChildren()[math.random(1, #script.Parent:GetChildren())]
	
	local TransparencyTween = TweenService:Create(part, TransparencyInfo, {Transparency = 1})
	local CFrameTween1 = TweenService:Create(part, FallInfo2, {CFrame = part.CFrame * CFrame.new(0, -30, 0)})
	local CFrameTween2 = TweenService:Create(part, FallInfo1, {CFrame = part.CFrame * CFrame.Angles(math.rad(math.random(-75, 75)), 0, math.rad(math.random(-75, 75)))})
	
	part.BrickColor = BrickColor.new("Black")
	task.wait(3)
	
	part.CanCollide = false
	TransparencyTween:Play()
	CFrameTween1:Play() --blocks the next cframe from playing properly
	CFrameTween2:Play() --yep this one
end

here’s the code

(forgot to mention but yes, I need them both separate because I need different time for positioning and rotating, so, yeah)

1 Like

I’m not that well versed in CFrame, but maybe you could try to use the Orientation property for the second tween?

1 Like

The second one doesn’t fire because both are manipulating the CFrame property. You can’t tween a single element of a CFrame, you have to manipulate it as a whole.

One way to fix this is to replace CFrame with Position and Orientation properties depending on the tween and fixing the goals.

2 Likes

You cant Tween a single part more than once.
If a Tween is running on a part and another Tween is called, the currently playing Tween will stop to allow the new Tween to play.

I said Tween way too much.

As @lnterstelI4r mentioned you cant play two tweens on the same instance more than once in this scenario…But to solve your problem you can either create instance Values such as NumberValue,CFrameValue etc to Tween their values which then you can apply the values to the allocated properties of your Part object.You can achieve this in a changed Event for the instance values to detect value changes.Otherwise,you can use tween.Completed to wait for a tween to complete.

1 Like

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