local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 0
while true do
t = 15
repeat
t = t-1
s.Value = "Intermission.. "..t
wait(1)
until t == 0
s.Value = "Game starting!"
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = "Loading "..mapselect[i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
local num = math.random(1,32)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=100
repeat
t = t-1
s.Value = t.." seconds left"
wait(1)
until t ==0 or vals.Winner.Value ~= ""
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " Has Won!"
game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
game.Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
else
s.Value = "No one has won!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
workspace[curmap]:Destroy()
end
✓ ANSWER ACCEPTED
How Do I Make My Script Start A New Game Once All Players Are Dead?
1 answer
✓ Accepted answer
You would have to make a table and then remove them once they have died. Example:
for x, player in pairs(plrs) do
if player then
character = player.Character
if not character then
-- left the game
table.remove(plrs,x)
else
if character:FindFirstChild("GameTag") then
-- They are still alive
print(player.Name.." is still in the game!")
else
-- They are dead
table.remove(plrs,x)
print(player.Name.." has been removed!")
end
end
else
table.remove(plrs,x)
print(player.Name.." has been removed!")
end
end
Then You would want to restart so when the player left in the table is <= 1 then you would do (Example):
if #plrs == 1 then
-- last person standing
Status.Value = "The Winner is "..plrs[1].Name
break
elseif #plrs == 0 then
Status.Value = "Nobody won!"
break
elseif i == 0 then -- This is the time of the match is up (If you have a certain time)
Status.Value = "Time's up!"
break
end
1 comment
0
Thank You Very Much
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
why are you posting your main script without an attempt?
the idea is to get those playing using a table, when a player dies they will be taken out of the table, once the table is empty, restart
whats wrong?
okay thank you i have tried but nothing works