How do I make the visibility false once the timer ends?

How can I make this Gui visibility false when the timer ends. As it goes false in the middle But I want it to wait until the timer finishes.

local Player = game.Players.LocalPlayer
local char = Player.Character
local Humanoid = char:WaitForChild("Humanoid")


Humanoid.Died:Connect(function(died)
	Player.PlayerGui:FindFirstChild("DeathGui"):WaitForChild("Frame").Visible = true
	for i = 5, 0, -1 do
		Player.PlayerGui:FindFirstChild("DeathGui").Frame.RespawnTimer.Text = "Respawning in "..i
		wait(1)
	end
	wait(5)
	Player.PlayerGui:FindFirstChild("DeathGui"):WaitForChild("Frame").Visible = false
end)

I think that is because you are waiting five seconds for it to go away. By the time you respawn, that script might go ahead and turn it to false (so say you reset, you wait five seconds for the countdown, respawn, and then reset again, but while the counter goes down, the GUI will turn invisible because of the previous task). Definitely not explaining it well, but I recommend you declare that you make the GUI ResetOnRespawn and put the script under the GUI itself. Not sure what else to recommend here.

1 Like

I didn’t quite understand anything but will still try what you said

It works perfectly, Thank you so much!

1 Like