You can use Player.Character.Humanoid.Died to listen out for when the player dies, then show the UI.
Listen out for Player.CharacterAdded to hide the UI when they respawn.
You do have to do this in a specific way, however, since the Character instance is changed each time. Here’s how I would do it:
local Players = game:GetService("Players")
Players.LocalPlayer.CharacterAdded:Connect(function(character)
-- Hide GUI
character.Humanoid.Died:Once(function()
-- Show GUI
end)
end)
I used Once instead of Connect here for the Humanoid.Died connection, as we only want to run the code to show the GUI once for each character.
If we use Connect, then the connection will persist, meaning that each time the death event is fired, the code will run for as many times as the player has died in total.
Absolutely not, I’m talking about those people who have access to forums and they ask such easy questions that can be found by writing the same forum title in Google. Although I probably shouldn’t run into them, because they are the ones who help us get +1 to the solutions in the profile.
respect that, however you can absolutely learn from youtube tutorials. also, i personally value speed a lot, so if i can do something quicker, achieve the same goal and learn, i’m doing that.