✓ Accepted answer
##Problem
Your script is inefficient constantly checking if the player's health is 0. This is unnecessary and if you have too many repeating loops, you might end up lagging your game.
##Solution
You can actually use the Died event of Humanoid. This script really should be put in a server script as it deals with the changing of teams.
With the died event, we want to establish PlayerAdded and CharacterAdded events as well.
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild('Humanoid').Died:connect(function()
Player.TeamColor = game.Teams.Dead.TeamColor
end)
end)
end)
######Hopefully this helped, if it did leave an upvote and if it answered your question do not forget to hit accept answer! If you have any questions or if the script produces an error feel free to comment below.