I am trying to make a round system in my game and I want the round to end when there is only 1 person alive, however it doesn't seem to be working, what happens is I start a local server simulation with 2 players and I reset one of them, after resetting them nothing seems to change. Here is the script (It is a regular script in the Workspace) :
playerTable = {}
players = game:GetService("Players")
plrs = game.Players:GetChildren()
-----------------------------------------------------------
--Removing
players.PlayerRemoving:Connect(function(player)
for i = 1,#playerTable do
if playerTable[i] == player then
print(""..player.." Has been removed from table")
table.remove(playerTable, i)
if #playerTable <= 1 then
game.ServerStorage.Values.InGame.Value = false
game.ServerStorage.Values.TopText.Value = "The winner is" (""..playerTable.."")""
end
end
end
end)
--Died
for i = 1,#playerTable do
playerTable[i].Character.Humanoid.Died:Connect(function()
table.remove(playerTable, i)
if #playerTable <= 1 then
game.ServerStorage.Values.InGame.Value = false
game.ServerStorage.Values.TopText.Value = "The winner is" (""..playerTable.."")""
end
end)
end
The script doesn't seem to do anything when I reset a player as a test

3 comments
How would I change it so it only activates when the player joins the game?
check my edit
did this work? please mark it as accepted if it works.