Hello!
I’m trying to make a round system, and it’s working rn but I want to add so that the round ends if there is 1 player remaining.
I’ve seen similar posts, but none of them worked as they were very old.
How could I do this?
local itemName = "Weapon"
local maps = game.ReplicatedStorage.Maps:GetChildren()
local status = game.ReplicatedStorage.Status
local gun = game.ReplicatedStorage.Weapon
while true do
task.wait(3)
for i = 25, 0, -1 do
status.Value = "Round starting in " ..i.. " seconds."
task.wait(1)
end
local mapClone = maps[math.random(1, #maps)]:Clone()
mapClone.Parent = game.Workspace
local spawnPoints = mapClone.TpPoints:GetChildren()
status.Value = "Mode: "..mapClone.Name
local arenaPoints = game.Workspace.Arena.TpPoints:GetChildren()
task.wait(3)
for i, player in pairs(game.Players:GetPlayers()) do
if player.Character then
player.weaponStats.InRound.Value = true
player.PlayerGui.Stats.Enabled = true
local chosenTp
repeat
chosenTp = spawnPoints[math.random(1, #spawnPoints)]
until chosenTp.Name ~= "Taken"
player.Character.HumanoidRootPart.CFrame = chosenTp.CFrame
chosenTp.Name = "Taken"
end
end
for i = 120, 0, -1 do
status.Value = "Loot up! "..i.." seconds remaining."
task.wait(1)
end
for i, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.weaponStats.InRound.Value == true then
local clone = gun:Clone()
clone.Configurations.MinDamage.Value = player.weaponStats.Damage.Value
clone.Configurations.MaxDamage.Value = player.weaponStats.Damage.Value
clone.Parent = player.Backpack
game.ReplicatedStorage.Remaining.Value = i
local choosenTp
repeat
choosenTp = arenaPoints[math.random(1, #arenaPoints)]
until choosenTp.Name ~= "Taken"
player.Character.HumanoidRootPart.CFrame = choosenTp.CFrame
choosenTp.Name = "Taken"
end
end
for i = 180, 0, -1 do
status.Value = "Fight! "..i.. " seconds remaining."
task.wait(1)
end
for i, player in pairs(game.Players:GetPlayers()) do
if player.Character then
player.Backpack:ClearAllChildren()
if player.Character and player.Character:FindFirstChild(itemName) and player.Character[itemName]:IsA("Tool") then
player.Character[itemName]:Destroy()
end
player.Character.HumanoidRootPart.CFrame = game.Workspace.Lobby.TpPoint.CFrame
player.weaponStats.InRound.Value = false
player.PlayerGui.Stats.Enabled = false
player.weaponStats.Damage.Value = 20
player.weaponStats.Health.Value = 100
end
end
status.Value = "Round over."
for i, v in pairs(spawnPoints) do
v.Name = "TpPoint"
end
mapClone:Destroy()
end