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.
The function wont repeat because the script waits 5 seconds, and the player respawns on 5 seconds So it will reset every thing on the character , You can make simply changing the global script to
script.Parent.ResetGuiSpawn.OnServerEvent:Connect(function(Player) Player.CharacterAdded:wait() local Char = Player.Character repeat wait() until Char == nil wait(1) Player.PlayerGui.ChangeTeam.Enabled = true end)
If it dont work, Communicate me