Hello there!
I’m trying to make a round system. I got it working but I want to ask, how do I make a round stop when all players have died? This is my attempt on it, but the round doesn’t even start.
local getFrame = game.StarterGui.IntermissionGUI.Frame
local roundTime = 100
local clientStarted = game.ReplicatedStorage.ClientStarted
local clientEnded = game.ReplicatedStorage.ClientEnded
local playersInRound = {}
local isOverrided = false
local getPlayers = game:GetService("Players")
while (#playersInRound ~= 0 and wait()) do
wait(13)
for _, plr in pairs(game.Players:GetChildren()) do
if plr.Character:FindFirstChild("HumanoidRootPart") then
plr.Character.HumanoidRootPart.CFrame = CFrame.new(53.55, 15.55, 57.1)
end
end
clientStarted:FireAllClients()
-- [PLAYER SYSTEM]
local playersInRound = {}
local playersDisconnected = {}
for _, Player in pairs(getPlayers:GetChildren()) do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
table.insert(playersInRound, Player)
playersDisconnected[Player.Name] = Player.Character.Humanoid.Died:Connect(function()
table.remove(playersInRound, table.find(playersInRound, Player))
end)
end
end
playersDisconnected["Removing"] = game.Players.PlayerRemoving:Connect(function(player)
local ind = table.find(playersInRound, player)
if ind then
table.remove(playersInRound, ind)
end
end)
if (#playersInRound == 0 and wait()) then
print("Everybody died!")
else
wait(100)
clientEnded:FireAllClients()
for _, plr in pairs(game.Players:GetChildren()) do
if plr.Character:FindFirstChild("HumanoidRootPart") then
plr.Character.HumanoidRootPart.CFrame = CFrame.new(53.55, 69.25, -113.35)
end
end
end
end
I think it’s because of the while (#playersInRound ~= 0 and wait()) do
that I added, but I don’t know how to do it in another way.