I wanted to make when Player is died will be run next code after
1 | v.Character.Humanoid.Died:connect( function () |
Can you help? This is won't work.
1 | local PlayersInTeam = game.Teams.Playing:WaitForChild( "PlayersInTeam" ) |
2 |
3 | for i,v in pairs (game.Teams.Playing:GetPlayers()) do |
4 | v.Character.Humanoid.Died:connect( function () |
5 | PlayersInTeam.Value = PlayersInTeam.Value - 1 |
6 | end ) |
7 | end |
Well if you are only running that loop 1 time, it SHOULD only work once. When a player dies, it creates a new Humanoid
, so the old one would be useless after the first death.
You could use...
1 | player.CharactedAdded:connect( function (character) |
2 | local humanoid = character:WaitForChild( "Humanoid" ) |
3 | humanoid.Died:connect( function () |
4 | PlayersInTeam.Value = PlayersInTeam.Value - 1 |
5 | end ) |
6 | end ) |
This would reset the death event every time a new character is added (which is every time the player dies and respawns).