How do I add a delay while tweening transparency of a frame?

Hello Fellow developers!

I want to make a loop where a frame smoothly goes visible and then back invisible. That’s why I used TweenService to tween the BackgroundTransparency of that frame. Here is the TweenInfo.

local fadeInfo = TweenInfo.new(
	1, --time it will take for tween to complete/reach goal
	Enum.EasingStyle.Sine, --tweening style
	Enum.EasingDirection.In, --tween easing style
	-1, --how many times will the tween repeat?
	true, --will tween reverse once completed?
	2 --delay before tween starts/reverses
)

As you could tell, the tween is looping and it will reverse. I also wrote 2 as a delay time before the tween reverses. But for some reason, it doesn’t work. When the frame is completely visible, the tween instantly reverses, instead of waiting 2 seconds.

Here is a small video of what I mean:

I used in pairs loops to make it work, I don’t think that’s the issue here.

for i, dots in pairs(Dotsfrm:GetChildren()) do
	if dots:IsA("Frame") then
		local fade = TweenService:Create(dots, fadeInfo, {BackgroundTransparency = 0})
		fade:Play()
	end
end

I tried using 2 different tweens, 1 for when it fades in and 1 when it fades out. But the result were disappointing. Maybe I did it wrong…

Any help is appreciated, Thanks in advance!

Try this:

fadeIn:Play();
fadeIn.Complete:Wait();
fadeOut:Play()
fadeOut.Complete:Wait()

I’ve encounter another problem.

Output:
Complete is not a valid member of Tween “Tween”

Do you maybe mean .completed instead of .Complete?

haha, true.

change Complete to Completed.
I wrote it wrong, sorry

1 Like

It works perfectly! Thank you for you time and help.

1 Like