Tween.Completed not working

So my problem when using .Completed:Wait() it doesn’t work with two tweens?

local function tweenClose()
	if leftGateTweenConnection and rightGateTweenConnection then
		leftGateTweenConnection:Pause()
		rightGateTweenConnection:Pause()
		leftGateTweenConnection = nil
		rightGateTweenConnection = nil
	end
	local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
	leftGateTweenConnection = TweenService:Create(LeftGate, tweenInfo, {Position = UDim2.new(0, 0, 0, 0)})
	leftGateTweenConnection:Play()
	
	rightGateTweenConnection = TweenService:Create(RightGate, tweenInfo, {Position = UDim2.new(0.5, 0, 0, 0)})
	rightGateTweenConnection:Play()
	
	leftGateTweenConnection.Completed:Wait()
	rightGateTweenConnection.Completed:Wait()
	
	print("close complete")
	return true
end

Do you want it to wait for both tweens to finish?

What won’t work? i don’t really understand.

The tween.Completed:Wait() does not fire when the tween is completed.

Maybe because the right one finished before left.

So how do I check if both tweens are complete?

Yes, but for some reason, it doesn’t work.

can you create a duplicate of the game and give me access?

It’s not seeing it. Did you share it with me yet?

I’m creating an easier version for you to edit.

1 Like

Gui Test.rbxl (48.0 KB)

Wait, if you are tweening GUI, don’t use TweenService. Use guiPart:TweenPosition().

I like using TweenService, it works everytime for me so I don’t think thats the problem.

Then try waiting running the right tween after the left tween runs.

What do you mean?

I want to play 2 tweens at the same time.

The reason why this doesn’t work is that they’re playing at the same time and ending at the same time, so you only need to wait for one to finish.

local function tweenClose()
	if leftGateTweenConnection and rightGateTweenConnection then
		leftGateTweenConnection:Pause()
		rightGateTweenConnection:Pause()
		leftGateTweenConnection = nil
		rightGateTweenConnection = nil
	end
	local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
	leftGateTweenConnection = TweenService:Create(LeftGate, tweenInfo, {Position = UDim2.new(0, 0, 0, 0)})
	leftGateTweenConnection:Play()
	
	rightGateTweenConnection = TweenService:Create(RightGate, tweenInfo, {Position = UDim2.new(0.5, 0, 0, 0)})
	rightGateTweenConnection:Play()
	
	leftGateTweenConnection.Completed:Wait()
	
	print("close complete")
	return true
end

What’s happening is that since they’re both playing at the same time, both ends, the first .Completed:Wait() finishes but the other one also finished. Waiting on one is sufficient enough since they’re ending at roughly the same time.

Thank you! Never knew about that.

1 Like

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