Help changing players team when they die

this code wont work!

local a = game:GetService(‘Players’).PlayerAdded
local b = a:WaitForChild(“Humanoid”)
while wait() do
if b.Died then
b.Team = “Zombie”
end
end

5 Likes

I would do something like

game.Players.PlayerAdded:Connect(function(plr)
 plr.CharacterAdded:Connect(function(char)
  char.Humanoid.Died:Connect(function()
   plr.Team = game.Teams.Zombie
  end)
 end)
end)
13 Likes

it worked! i just needed to change the code on line four to game.Teams.Zombie and it worked!

4 Likes