How do I make a GUI go away next life?

I’m making a team change GUI, and once you click it, it changes your team, respawns you, then makes the GUI invis.
Code:


local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local items = script.Parent:GetChildren()
for i,v in pairs(items) do
	if v:IsA("TextButton") then
		table.insert(newTable,v)
	end
end
for i,v in pairs(newTable) do
	v.MouseButton1Click:Connect(function()
		script.Parent.splat:Play()
		local plr = script.Parent.Parent.Parent.Parent
		print(plr.Name)
		local team = game.Teams:FindFirstChild(v.Text)
		plr.TeamColor = team.TeamColor
		plr:LoadCharacter()
		wait(7)
		plr.PlayerGui.MainMenu.Enabled = false
	end)
end```

Try setting the UIs resetOnSpawn Value to false, so it isn’t replicated upon death.

I tried this and put it before my loadcharacter and there’s 2 screenguis now.
(when I look at the player)

fixed it by making the gui resetonspawn = false

how do I make it resetonspawn afterwards so when you reset the menu pops back up, it deletes itself even though it’s before my LoadCharacter