for i, player in pairs(Players) do
local Humanoid = player.Character:WaitForChild("Humanoid")
deathConnection = Humanoid.Died:Connect(function()
print(player.Name .. " Died!")
deathConnection:Disconnect()
print("Connection disconnected")
local Index = table.find(Connections, deathConnection)
if Index ~= nil then
table.remove(Connections, Index)
print("Removed connection from connection table")
end
table.insert(PlayersWhoDied, 1, player)
print("Added player to PlayerWhoDied table")
local Index = table.find(Players, player)
print("Index is " .. Index)
if Index ~= nil then
print("Index found!")
table.remove(Players, Index)
print("Removed " .. player.Name)
end
end)
table.insert(Connections, deathConnection)
end
This code works just fine and works very well when one player dies. The problem is, when two people die at the same time, the code only runs for one of the players. It’s as if it completely ignores that the second player died.
I loop through all the players in the round, setup died events for all of them, and when they die I run the code for my round winning system.
So the problem: When 2(maybe more) people die at the same time, only one of the events run.