I want to make the place destroy after everyone is dead. I did it once but I need itt a second time, but this ttime when everyone dies it's over. I tried an Ifelse statement, but that didn't work. Any suggestions?
LOF = game.Lighting.LOFgames:GetChildren()
h = script.Parent
f = script.Parent.Parent
gamePlayers = game.Players:GetPlayers()
while true do
if game.Players.NumPlayers > 0 then
wait(3)
f.Visible = true
h.Visible = true
h.Text = "Wait 10 seconds to get situated!"
wait(10)
h.Text = "Deciding which Leap of Doom- uh I mean Faith for you to do!"
wait(10)
ranGame = math.random (1, #LOF)
gameChosen = LOF[ranGame]
h.Text = "HAHAHAHA YOUR DOOM- I MEAN YOUR LEAP OF FAITH GAME: " .. gameChosen.Name
wait(10)
gameChosenClone = gameChosen:Clone()
gameChosenClone.Parent = game.Workspace
thing = gameChosenClone.thing:GetChildren()
--teleportation :D
for i, v in pairs(game.Players:GetPlayers()) do
name = v.Name
check = game.Workspace:FindFirstChild(name)
if check then
checkHumanoid = check:FindFirstChild("Humanoid")
if checkHumanoid then
v.Character:MoveTo(thing[i].Position)
end
end
end
for i = 8, 1, -1 do
h.Text = "FAITH WILL START IN " .. i
end
for i = 60, 1, -1 do
wait(0.5)
h.Text = "THE COUNTDOWN BEGINS, TIME:" ..i
end
h.Text = "Game Ended hopefully you survived! :)"
wait(5)
gameChosenClone:Destroy()
end
wait(1)
end
I'm not sure if you need the whole code, but there you go. Also the script is in a gui in starter gui. My main problem is that everytime You die then the script restarts anyway to change it from restarting once you die? Here is my New script...
LOF = game.ServerStorage.LOFgames:GetChildren()
h = script.Parent
f = script.Parent.Parent
gamePlayers = game.Players:GetPlayers()
local roundTime = 30
while true do
if game.Players.NumPlayers > 0 then
wait(3)
f.Visible = true
h.Visible = true
h.Text = "Intermission"
wait(10)
h.Text = "Deciding which Leap of Doom- uh I mean Faith for you to do!"
wait(5)
ranGame = math.random (1, #LOF)
gameChosen = LOF[ranGame]
h.Text = "HAHAHAHA YOUR DOOM- I MEAN YOUR LEAP OF FAITH GAME: " .. gameChosen.Name
wait(5)
gameChosenClone = gameChosen:Clone()
gameChosenClone.Parent = game.Workspace
thing = gameChosenClone.thing:GetChildren()
for i = 8, 1, -1 do
h.Text = "FAITH WILL START IN " .. i
end
wait(8)
local playersTeleported = {}
--teleportation :D
for i, v in pairs(game.Players:GetPlayers()) do
name = v.Name
check = game.Workspace:FindFirstChild(name)
if check then
checkHumanoid = check:FindFirstChild("Humanoid")
if checkHumanoid then
table.insert(playersTeleported, v)
v.Character:MoveTo(thing[i].Position)
end
end
end
local function WaitForPlayersToDie(playersTeleported, maxTime)
local playersAlive = {}
if #playersTeleported == 0 then return end
local allDead = true
for i = 1, #playersTeleported do
local player = playersTeleported[i]
local con
local function disconnect()
for i = 1, #playersAlive[player] do
playersAlive[player]:disconnect()
end
playersAlive[player] = nil
allDead = next(playersAlive) == nil
end
playersAlive[player] = {
player.AncestryChanged:connect(disconnect),
player.CharacterRemoving:connect(disconnect),
Disconnect=disconnect,
}
end
local start = workspace.DistributedGameTime
while workspace.DistributedGameTime - start < maxTime do
wait(1)
if allDead then break end
end
for player, connections in pairs(playersAlive) do
connections.Disconnect()
end
end
local roundDone = false
coroutine.resume(coroutine.create(function()
for i = roundTime * 2, 1, -1 do
wait(0.5)
if roundDone then return end
h.Text = "THE COUNTDOWN BEGINS, TIME:" ..i
end
end))
WaitForPlayersToDie(playersTeleported, roundTime)
roundDone = true
h.Text = "Game Ended hopefully you won! :)"
wait(5)
gameChosenClone:Destroy()
else
end
wait(1)
end

1 comment
you could try getting the number of people in the game area and when someone dies, it takes a number off and when it's 0, boom. btw i dont see a line for when everybody is dead. or i just read over it.