Reset-GUI time too fast

Hello,

Currently I’m working on a feature which requires a GUI to appear when the player dies/resets their character. The GUI uses tweening to create a fade in/out effect.

I’m trying to make the GUI stay for 2 seconds in between the fade tweens. However, it does not wait before moving on to the second (fade out) effect.

The script:

local player = game.Players.LocalPlayer
local Fade = script.Parent.Frame

player.Character:WaitForChild('Humanoid').Died:Connect(function()
	
	Fade.Visible = true
	
	--The first tween (fade in)
	local Info = TweenInfo.new(1)
	local Tween = game:GetService("TweenService"):Create(Fade,Info,{BackgroundTransparency=0})
	Tween:Play()
	
	wait(2)
	
	--The second Tween (fade out)
	local Info = TweenInfo.new(1)
	local Tween = game:GetService("TweenService"):Create(Fade,Info,{BackgroundTransparency=1})
	Tween:Play()
	
	wait(2)
	
	Fade.Visible = false
	
end)

Also, Players.RespawnTime is set to 3.

I think you can use Tween.Completed:Wait() for this, it waits for the tween to finish and then waits 2 seconds and plays the other tween

local player = game.Players.LocalPlayer
local Fade = script.Parent.Frame

player.Character:WaitForChild('Humanoid').Died:Connect(function()
	
	Fade.Visible = true
	
	--The first tween (fade in)
	local Info = TweenInfo.new(1)
	local Tween = game:GetService("TweenService"):Create(Fade,Info,{BackgroundTransparency=0})
	Tween:Play()
	
	Tween.Completed:Wait()
	
	wait(2)
	
	--The second Tween (fade out)
	local Info = TweenInfo.new(1)
	local Tween = game:GetService("TweenService"):Create(Fade,Info,{BackgroundTransparency=1})
	Tween:Play()
	
	Tween.Completed:Wait()
	
	wait(2)
	
	Fade.Visible = false
	
end)
2 Likes