So I am trying to make a mini game game, however I have no clue on how to add a check to see if all players have died, can someone help me?
So here is the script.
wait(2)
local select = script.Rounds:GetChildren()
local h = script:WaitForChild("Status")
function start()
if game.Players.NumPlayers >= 1 then
wait(3)
wait(1)
h.Value = "Choosing gamemode!"
local roundchosen = math.random(1, #select)
wait(.1)
local round = select[roundchosen]
print("Chosen round: " .. round.Name)
wait(3)
if round.Name == "FFA" then
FFA()
elseif round.Name == "DODGEMS" then
DODGEMS()
elseif round.Name == "SFFA" then
h.Value = "Gamemode chosen: " .. round.Name
wait(3)
SFFA()
end
else
h.Value = "Waiting for 2 players too start!"
wait(1)
start()
end
end
function SFFA()
local maps = game.Lighting.Maps.FFA:GetChildren()
h.Value = "Choosing map.."
wait(3)
print("Map selection")
local mapchosen = math.random(1, #maps)
local map = maps[mapchosen]
print(map.Name)
wait(4)
local mapclone = map:Clone()
mapclone.Parent = game.Workspace
mapclone:MakeJoints()
wait(4)
for _, player in pairs(game.Players:GetPlayers()) do
local contestants = {}
table.insert(contestants, player)
local spawnmodel = map.Spawns:GetChildren()
local spawn = math.random(1, #spawnmodel)
local spawnchosen = spawnmodel[spawn]
player.Character.Torso.CFrame = CFrame.new(spawnchosen.Position + Vector3.new(0, 3, 0))
spawnchosen:Destroy()
end
for i = 60, 1, -1 do
h.Value = "Time left: " .. i -- The check would go here.
wait(1)
end
start()
end

5 comments
Umm so where u do the loop just put local c??
Put the whole local c line local c = coroutine.resume(coroutine.create(function() OnDied() end)) after line 53 in your script.
Umm so if I just put it there, it will just do the function, how do I make it stop the function if only 1 or 0 people are left?
Bump
Are all your alive players gonna be in the contestants table? So you want them removed from there when they die too?