Before I say anything you guys should know that my game is a game where there is one person who is "it" and they have to try to kill everybody else. What I want to happen in this piece of code is to create a table of the players, and remove them from the table if they die OR leave the game. The players seem to get removed when they leave the game, but if they are kill by the person whos it, they don't seem to be removed from the table. Help?!
local localtimer = roundtime activecontestants = {unpack(contestants)} while true do wait(1) localtimer = localtimer - 1 status.Value = localtimer if localtimer < 2 or #activecontestants == 1 then break end end for index, player in pairs(activecontestants) do -- Set up the Died event. if player.Character and player.Character:FindFirstChild("Humanoid") then player.Character.Humanoid.Died:connect(function() for index2, player2 in pairs(activecontestants) do -- This second loop is a precaution because the table may have changed by the time they died. if player2 == player then table.remove(activecontestants, index2) end end end) end end game.Players.PlayerRemoving:connect(function(p) -- Set up the PlayerRemoving event. for index, player in pairs(activecontestants) do if player == p then table.remove(activecontestants, index) end end end)