Hello guys. I have been trying to make a team selecter GUI for a game. I know there is something called resetonspawn , but its not very good in my situation. Everytime the script changes the team it does player:LoadCharacter() that way the player just keeps spawning with the gui. The script I have right now resets after the player dies, but only one time.
Here is my localscript:
local ResetGui = script.Parent.ResetGuiSpawn
local Gui = script.Parent.Parent
ImmigrantButton.MouseButton1Down:Connect(function(player)
Gui.Enabled = false
RE:FireServer(BrickColor.new(IT)) -- This doesn't matter.
ResetGui:FireServer()
end)
And my script:
script.Parent.ResetGuiSpawn.OnServerEvent:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
Char.Humanoid.Died:Connect(function()
wait(5);
Player.PlayerGui.ChangeTeamGui.Enabled = true;
end)
end)
end)
Any help would be much appreciated!
Edit: I found out a solution myself, but thanks for the answer.

3 comments
Could you answer with the lua function? I don't understand the script dowsn't work now.
The script completely stopped working. Idk what I did wrong.
Done, I forgot the lua function lol