Hi. I'm trying to make a radio. However, when I reset, it decides to not work. There's a gamepass involved, and I don't know why it won't work. I've disabled "ResetOnSpawn" and it sorta works, but I need a way to make the GUI destroy itself when the player resets.
✓ ANSWER ACCEPTED
How do I make the GUI to Destroy Itself when Player Resets without ResetOnSpawn?
1 answer
✓ Accepted answer
Hello, the following script should help you
local PlayerService = game:GetService("Players")
PlayerService.PlayerAdded:Connect(function(Player) -- Event called when a new Player joins
Player.CharacterAdded:Connect(function(Character) -- Waits for character to be added into workspace
Character:WaitForChild("Humanoid").Died:Connect(function() -- Event is fired when the player died
local PGUI = Player:WaitForChild("PlayerGui") -- PlayerGui is used to get UI Elements in players
local UIToRemove = PGUI:WaitForChild("GUINAME") -- Put your Gui name where GUINAME is
UIToRemove:Destroy() -- Destroys UI
return
end)
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
did you try the Player.Died event?
I don't know how to make the GUI destroy itself though.
use :Destroy()?