if game.Workspace.GameMode.Value == "FFA" then --FFA gamemode
local spawnsTable = {}
for i, v in pairs(chosenClone.Spawns:GetChildren()) do
if v.Name == "Spawn" then
spawnsTable[#spawnsTable + 1] = v
end
end
local playersAlive = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v.Character.Humanoid.Health == 0 then return end
v.Character:MoveTo(spawnsTable[math.random(1, #spawnsTable)].Position)
local sword = game.ReplicatedStorage.ClassicSword:Clone()
sword.Parent = v.Backpack
playersAlive[#playersAlive + 1] = v
end
for i, v in pairs(playersAlive) do
v.Character.Humanoid.Died:Connect(function()
table.remove(playersAlive, i)
end)
end
while true do
wait()
if #playersAlive > 1 then return end
break
end
editGUI("ChangeText", playersAlive[1].Name.." wins!")
wait(3)
chosenClone:Destroy()
playersAlive[1]:LoadCharacter()
end
I am trying to make a sword fighting game (the script is too long so i did not include it all,just the important part). The problem is that when a player dies, it does not gt removed from the playersAlive table, and the round will not end. Can someone please fix my code or find a more efficient way to do this? Thanks.

2 comments
table.remove(playersAlive, table.find(playersAlive, v))
@Ziffixture, same result, but at least you answered another question i had, i think it has something to do with the event