Hello! I am making a round system for my game and it works! I am trying to achieve something so that the round stops when all players have died/disconnected but have no clue on where to start. Any help is appreciated!
Script:
local Obbies = game.ReplicatedStorage.Obbies
local PlayersInGame = {}
local playersDisconnected = {}
local inRound = false
local Status = game.ReplicatedStorage.Values.Status
local EasyObby = nil
local EasyNum = math.random(1, 3)
if EasyNum == 1 then
EasyObby = Obbies.Easy["Cake Walk - Easy"]:Clone()
EasyObby.Parent = game.Workspace
EasyObby:SetPrimaryPartCFrame(CFrame.new(-636.45, 51.9, -110.35))
elseif EasyNum == 2 then
EasyObby = Obbies.Easy["One Jump - Easy"]:Clone()
EasyObby.Parent = game.Workspace
EasyObby:SetPrimaryPartCFrame(CFrame.new(-636.45, 51.9, -110.35))
elseif EasyNum == 3 then
EasyObby = Obbies.Easy["Legit Just a Cake Walk - Easy"]:Clone()
EasyObby.Parent = game.Workspace
EasyObby:SetPrimaryPartCFrame(CFrame.new(-636.45, 51.9, -110.35))
end
for i, v in pairs(game.Players:GetPlayers()) do
v.PlayerInGame.Value = true
v.Character.HumanoidRootPart.CFrame = EasyObby.PrimaryPart.CFrame
table.insert(PlayersInGame, v)
end
local MediumNum = math.random(1, 3)
local MediumObby = nil
if MediumNum == 1 then
MediumObby = Obbies.Medium["Lava Jumps - Medium"]:Clone()
MediumObby.Parent = game.Workspace
MediumObby:SetPrimaryPartCFrame(CFrame.new(-520.95, 51.9, -110.35))
elseif MediumNum == 2 then
MediumObby = Obbies.Medium["Big Lava Jump - Medium"]:Clone()
MediumObby.Parent = game.Workspace
MediumObby:SetPrimaryPartCFrame(CFrame.new(-520.95, 51.9, -110.35))
elseif MediumNum == 3 then
local MediumObby = Obbies.Medium["WHAT?! HOW?! - Medium"]:Clone()
MediumObby.Parent = game.Workspace
MediumObby:SetPrimaryPartCFrame(CFrame.new(-520.95, 51.9, -110.35))
end
local HardNum = math.random(1, 3)
local HardObby = nil
if HardNum == 1 then
HardObby = Obbies.Hard["Guesser - Hard"]:Clone()
HardObby.Parent = game.Workspace
HardObby:SetPrimaryPartCFrame(CFrame.new(-577.55, 51.9, -110.35))
elseif HardNum == 2 then
local HardObby = Obbies.Hard["Guesser 2.0 - Hard"]:Clone()
HardObby.Parent = game.Workspace
HardObby:SetPrimaryPartCFrame(CFrame.new(-577.55, 51.9, -110.35))
elseif HardNum == 3 then
HardObby = Obbies.Hard["Extreme Lava Jumps - Hard"]:Clone()
HardObby.Parent = game.Workspace
HardObby:SetPrimaryPartCFrame(CFrame.new(-577.55, 51.9, -110.35))
end
for i = 60, 0, -1 do
if i > 1 then
wait(1)
Status.Value = "In Game: "..i.." seconds until game is over!"
elseif i == 1 then
wait(1)
Status.Value = "In Game: "..i.." second until game is over!"
else
wait(1)
Status.Value = "Time's up!"
wait(1)
for i, v in pairs(game.Players:GetPlayers()) do
if v.PlayerInGame.Value == true then
v.PlayerInGame.Value = false
v.Character.Humanoid.Health = 0
table.remove(PlayersInGame, table.find(PlayersInGame, v))
end
end
EasyObby:Destroy()
MediumObby:Destroy()
HardObby:Destroy()
end
end