Wait until tween is completed

I was wondering how I could add something to wait until a tween is finished, activating something else. In this case I was wanting for a GUI to become visible, then resized using a tween two times, and then when those tweens are completed for the GUI to become invisible. Although I am not sure what I could do to wait until the tween is finished.

Here is some script I quickly put together which works fine up until the second TweenSize is being played. I also should mention that this is a local script.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Bar1 = game.Players.LocalPlayer.PlayerGui:WaitForChild("Bars").Bar1

local function SizeBar1()
	if Bar1.Visible == false then
	    Bar1.Visible = true
        Bar1:TweenSize(UDim2.new(0, 360, 0, 12), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 1, true)
        wait(3)
		Bar1:TweenSize(UDim2.new(0, 0, 0, 12), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1, true)
-- Something here to wait until tween is completed
        **Bar1.Visible = false** - 
    end
end

SizeBar1()

Because the problem I have so far is that the GUI goes invisible in the middle of the tween being activated, instead of just waiting until it finishes. I would appreciate some assistance, thanks.

Why not just add `task.wait(1)

2 Likes

tween.completed:wait()

not the exact way to type it but auto fill should help properly capitalize letters

3 Likes

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