It would probably be easiest to not use an anonymous function (at least for the PlayerAdded event), then just wait a certain time before connecting the function to the event. So,
function changeTeam(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
player.TeamColor = BrickColor.new("Bright orange")
end)
end)
end
wait(50)
game.Players.PlayerAdded:connect(changeTeam)
However, once this is connected, it will stay connected. If you want to be able to stop this script from working whenever you want, you use the disconnect() method.
function changeTeam(player)
CA = player.CharacterAdded:connect(function(character)
D = character:WaitForChild("Humanoid").Died:connect(function()
player.TeamColor = BrickColor.new("Bright orange")
end)
end)
end
wait(50)
PA = game.Players.PlayerAdded:connect(changeTeam)
CA:disconnect()
D:disconnect()
PA:disconnect()
1 comment
If you wait, the player might enter before the PlayerAdded event is connected. It's not permanently disabled, it's just disabled for the first person who enters the game.