How To Make Two Tweens take turns playing

Hi! Im trying to make a tree, that has leaves, and the leaves take turns rotating left to right. I want that to be looped, like infinite. My current script doesnt work for some reason. Im not sure what im doing wrong, but any help could be appreciated. Here is the script:

local Tween = game:GetService("TweenService")
local part = script.Parent
turn = 1
cooldown = false


local Info = TweenInfo.new(
	5,
	Enum.EasingStyle.Back,
	Enum.EasingDirection.Out,
	1,
	true,
	0
)



local MoveLeaves1 =
{
		Size = Vector3.new(2.107, 7.35, 2.107);	
		Orientation = Vector3.new(0,0,2);
		Position = script.Parent.Position - Vector3.new(0.2, 0, 0)
}

local MoveLeaves2 =
	{
		Size = Vector3.new(2.107, 7.35, 2.107);	
		Orientation = Vector3.new(0,0,-2);
		Position = script.Parent.Position + Vector3.new(0.2, 0, 0)
	}



local leafmover = Tween:Create(part, Info, MoveLeaves1)
local leafmover2 = Tween:Create(part, Info, MoveLeaves2)

while true do
	wait()
	if cooldown == false then
		cooldown = true
		if combo == 1 then
			combo = 2
			leafmover:Play()
		elseif combo == 2 then
			combo = 1
			leafmover2:Play()
		end
		wait(6)
		cooldown = false
	end
end

Try using the .Completed Event of the TweenBase, e.g:

while true do 
     wait()
     leafmover:Play()
     leafmover.Completed:Wait()
     
     ā€” add a wait here if you want

     leafmover2:Play()
     leafmover2.Completed:Wait()  
 end
2 Likes

Now it finally works! Thank you very much!

1 Like