I wanted to make when Player is died will be run next code after
v.Character.Humanoid.Died:connect(function()
Can you help? This is won't work.
local PlayersInTeam = game.Teams.Playing:WaitForChild("PlayersInTeam") for i,v in pairs(game.Teams.Playing:GetPlayers()) do v.Character.Humanoid.Died:connect(function() PlayersInTeam.Value = PlayersInTeam.Value - 1 end) 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...
player.CharactedAdded:connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:connect(function() PlayersInTeam.Value = PlayersInTeam.Value - 1 end) end)
This would reset the death event every time a new character is added (which is every time the player dies and respawns).