Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would you make a frame visible only for a certain amount of time?

Ex: when you die a frame gui stays on your screen for 5 seconds

Thats an example dont do. do it only if you want to .-.

2 answers

✓ Accepted answer

You will want to use the .Enabled property of frames.

Put a frame in a ScreenGui and put a localscript inside the frame. Then, you can use the Humanoid.Died event to check when you died.

local frame = script.Parent
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
	frame.Enabled = true
	wait(5)
	frame.Enabled = false
end)

However, if the player respawns within 5 seconds, the character's startguis will be destroyed and new ones will be cloned. There are ways to circumvent this such as disabling Player.CharacterAutoLoads and showing the screen for 5 seconds, and then manually respawning them yourself.

If you want to make a death screen, then here's how you do it.

Make your death gui

Set Enabled to false on the gui

Set ResetOnSpawn to true on the gui

Then add the following script to the gui:


repeat
	wait()
until game.Players.LocalPlayer.Character

char = game.Players.LocalPlayer.Character


local humanoid = char:WaitForChild("Humanoid")

humanoid.Died:Connect(function()
	script.Parent.Enabled = true
end)


Make sure the script is directly in the gui

Hope this works!

This discussion is preserved as it was. New answers, comments, and votes are closed.