#how i make round stop early if all players dead 😴

1 messages · Page 1 of 1 (latest)

bleak merlin
#
--Customize
local IntermissionTime = 10
local RoundTime = 30
local MinPlayers = 0

--Variables
local Players = game:GetService("Players")

local Remote = game.ReplicatedStorage:WaitForChild("AFKRemote")

local PeriastronFolder = game.ServerStorage.Periastrons
local Periastrons = PeriastronFolder:GetChildren()

--SetUp
Players.PlayerAdded:Connect(function(plr)
    local InGame = Instance.new("BoolValue", plr)
    InGame.Name = "InGame"
    InGame.Value = false
end)

--Functions
local function TPPlayers()
    for i, player in Players:GetPlayers() do
        if not player.Character.HumanoidRootPart then return end
        player.Character.HumanoidRootPart.Position = Vector3.new(math.random(-124.5, 124.5), 10, math.random(-124.5, 124.5))
    end
end

local function GiveItems()
    for i, player in Players:GetPlayers() do
        local RandomItem = Periastrons[math.random(1, #Periastrons)]
        local Clone = RandomItem:Clone()
        Clone.Parent = player.Backpack
    end
end

local function KillAll()
    for i, player in Players:GetPlayers() do
        player.Character.Humanoid.Health = 0
    end
end

local function Countdown(duration)
    for i=duration, 1, -1 do
        workspace:SetAttribute("Clock", i)
        task.wait(1)
    end
end

local function IntermissionStart()
    print("Intermission")
    workspace:SetAttribute("Status", "Intermission")
    KillAll()
    Countdown(IntermissionTime)
end

local function RoundStart()
    print("Game start")
    workspace:SetAttribute("Status", "Game")
    TPPlayers()
    GiveItems()
    Countdown(RoundTime)
end

--Loop Looper
while task.wait() do
    if #Players:GetPlayers() >= MinPlayers then
        IntermissionStart()
        RoundStart()
    else
        print("waiting for players")
    end
end```
narrow charm
#

Then if its 0 u break the loop and do ur stuff

bleak merlin
kindred wolf
#

I know, revolutionary

bleak merlin
kindred wolf
#

In the loop you want to break

bleak merlin
#

Ok

#

thanks

kindred wolf
#

preferably after a condition, so it only breaks once certain conditions are met; i.e. players alive

bleak merlin
#
local function Countdown(duration)
    for i=duration, 1, -1 do
        if #GetAlivePlayers() <= 1 or nil then
            break
        end
        workspace:SetAttribute("Clock", i)
        task.wait(1)
    end
end```
#

like ts

brisk cobalt
#

you could move all the dead players to a spectate team

#

and then all youd need to do is check if any players aren't in it