Hide UI on Death

Hey! I have a roleplay type game where you can explore and fight etc.

There are also some ways to die, and since this is roleplay based, I want to have as much realism as possible.

I already have a “black screen on death” script which shows to the user once they die, and disappear when they respawn 7.5 seconds later.

I want to increase this further by disabling the healthbar, playerlist, topbar etc for 7.5 seconds when you die and reappear once you respawn.

I appreciate any help. Thank you!

local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.(**choose one**), false)

Thank you! Where would I place this? I also assume this is a localscript.

Make it a local script, yeah. I usually put it in StarterGui.

How would I make it hide on death and reappear on respawn? The respawn time is 7.5 seconds.

Ok so how do you detect when a player dies? Or do you have such script or not?

I have a GUI that shows a black screen when you die but I also want the UI to hide

You can use the Humanoid.Died event, and then the CharacterAdded event to re-enable the UI

What would I parent the LS to?

Then just add my code the the place in your code where you create a black screen. And when you remove the black screen, run this code too:

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

true just means you want to enable it

Either StarterPlayerScripts or StarterGui. Make sure it’s not in StarterCharacterScripts

Thank you both very much. I’ll take it from here and let you know if I run into issues.

1 Like

By the way, with the Enum part, you can just choose Enum.CoreGuiType.All and thats is going to disable all gui (except for roblox logo in the top left corner). And the second boolean value you input into StarterGui:SetCoreGuiEnabled() is just if you want to enable or disable it (true = enable, false = disable).

1 Like