-
What do you want to achieve?
A working round system -
What is the issue?
when there are 2 players left in the server and then a player left the game, the round system immediately stops like the timer just stuck and doesn’t change.
Error:
-
What solutions have you tried so far?
No results when finding on other social medias
Code:
local roundLength = 50
local intermissionLength = 20
local SplitUpTime = 4
local inRound = game.ReplicatedStorage.InRound
local SpawnLocation1 = game.Workspace.SpawnLocation3
local status = game.ReplicatedStorage.Status
local startgameSafe = {game.Workspace.SafeStartGame}
local mapsFolder = game.ReplicatedStorage.Maps
local Maps = mapsFolder:GetChildren()
local FightArea2 = game.Workspace.FightArea2
local FightArea3 = game.Workspace.FightArea3
while true do
task.wait()
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player)
end
end
for i = intermissionLength, 1, -1 do
task.wait(1)
status.Value = "Intermission: " .. i .. " seconds left"
end
local chosenMap = Maps[math.random(1, #Maps)]
local ClonedMap = chosenMap:Clone()
ClonedMap.Parent = game.Workspace
for i = 2, 1, -1 do
task.wait(1)
status.Value = chosenMap.Name.." has been chosen!"
end
for i = 3, 1, -1 do
task.wait(1)
status.Value = "Teleporting players in "..i
end
local player = game.Players:GetChildren()
for i = 1, #player do
if game.Workspace:FindFirstChild("Old Roblox") then
if player[i].afkMode.Value == true then
else
local char = player[i].Character
local OldRobloxSpawnPoints = game.Workspace.OldRobloxSpawnPoints:GetChildren()
char:FindFirstChild("HumanoidRootPart").CFrame = OldRobloxSpawnPoints[math.random(1, #OldRobloxSpawnPoints)].CFrame + Vector3.new(0,3,0)
local Gametag = Instance.new("BoolValue")
Gametag.Name = "GameTag"
Gametag.Parent = char
end
elseif game.Workspace:FindFirstChild("Lost Arena") then
if player[i].afkMode.Value == true then
else
local char = player[i].Character
char:FindFirstChild("HumanoidRootPart").CFrame = FightArea2.CFrame
local Gametag = Instance.new("BoolValue")
Gametag.Name = "GameTag"
Gametag.Parent = char
end
elseif game.Workspace:FindFirstChild("Season Memory") then
if player[i].afkMode.Value == true then
else
local char = player[i].Character
char:FindFirstChild("HumanoidRootPart").CFrame = FightArea3.CFrame
local Gametag = Instance.new("BoolValue")
Gametag.Name = "GameTag"
Gametag.Parent = char
end
elseif game.Workspace:FindFirstChild("Zoyna Grass") then
if player[i].afkMode.Value == true then
else
local char = player[i].Character
local availableSpawnPoints = game.Workspace.AvailableSpawnPoints:GetChildren()
char:FindFirstChild("HumanoidRootPart").CFrame = availableSpawnPoints[math.random(1, #availableSpawnPoints)].CFrame + Vector3.new(0,10,0)
local Gametag = Instance.new("BoolValue")
Gametag.Name = "GameTag"
Gametag.Parent = char
end
elseif game.Workspace:FindFirstChild("Sky Temple") then
if player[i].afkMode.Value == true then
else
local char = player[i].Character
local SkyTempleSpawnPoints = game.Workspace.TempleSpawnPoints:GetChildren()
char:FindFirstChild("HumanoidRootPart").CFrame = SkyTempleSpawnPoints[math.random(1, #SkyTempleSpawnPoints)].CFrame
local Gametag = Instance.new("BoolValue")
Gametag.Name = "GameTag"
Gametag.Parent = char
end
end
end
if game.Workspace:FindFirstChild("Old Roblox") then
local cloening = game.Workspace.KillStartGame:Clone()
cloening.Parent = game.Workspace
cloening.Position = Vector3.new(444.831, 95.892, -244.572)
cloening.Size = Vector3.new(382.31, 211.879, 375.354)
for x = SplitUpTime, 1, -1 do
task.wait(1)
status.Value = "Split up..("..x..")"
end
cloening:Destroy()
local CLONING = game.Workspace.KillStartGame:Clone()
CLONING.Parent = game.Workspace
CLONING.Position = Vector3.new(398.001, -11.997, -119.506)
CLONING.Size = Vector3.new(250, 127.75, 230.5)
task.wait(1)
CLONING:Destroy()
elseif game.Workspace:FindFirstChild("Lost Arena") then
local cloening = game.Workspace.SafeStartGame:Clone()
cloening.Parent = game.Workspace
cloening.Position = Vector3.new(398.399, 68.09, 153.936)
cloening.Size = Vector3.new(174, 159, 200)
for x = SplitUpTime, 1, -1 do
task.wait(1)
status.Value = "Split up..("..x..")"
end
cloening:Destroy()
local CLONING = game.Workspace.KillStartGame:Clone()
CLONING.Parent = game.Workspace
CLONING.Position = Vector3.new(398.399, 68.09, 153.936)
CLONING.Size = Vector3.new(174, 159, 200)
task.wait(1)
CLONING:Destroy()
elseif game.Workspace:FindFirstChild("Season Memory") then
local cloening = game.Workspace.SafeStartGame:Clone()
cloening.Parent = game.Workspace
cloening.Position = Vector3.new(111.937, 94.313, 269.332)
cloening.Size = Vector3.new(152.436, 136.67, 164.749)
for x = SplitUpTime, 1, -1 do
task.wait(1)
status.Value = "Split up..("..x..")"
end
cloening:Destroy()
local CLONING = game.Workspace.KillStartGame:Clone()
CLONING.Parent = game.Workspace
CLONING.Position = Vector3.new(111.937, 94.313, 269.332)
CLONING.Size = Vector3.new(152.436, 136.67, 164.749)
task.wait(1)
CLONING:Destroy()
elseif game.Workspace:FindFirstChild("Zoyna Grass") then
local cloening = game.Workspace.SafeStartGame:Clone()
cloening.Parent = game.Workspace
cloening.Position = Vector3.new(-126.102, 39.862, 307.741)
cloening.Size = Vector3.new(209.931, 125.686, 211.61)
for x = SplitUpTime, 1, -1 do
task.wait(1)
status.Value = "Split up..("..x..")"
end
cloening:Destroy()
local CLONING = game.Workspace.KillStartGame:Clone()
CLONING.Parent = game.Workspace
CLONING.Position = Vector3.new(-126.102, 39.862, 307.741)
CLONING.Size = Vector3.new(209.931, 125.686, 211.61)
task.wait(1)
CLONING:Destroy()
elseif game.Workspace:FindFirstChild("Sky Temple") then
local cloening = game.Workspace.SafeStartGame:Clone()
cloening.Parent = game.Workspace
cloening.Position = Vector3.new(-386.566, 22.128, 23.452)
cloening.Size = Vector3.new(290.586, 208.991, 281.654)
for x = SplitUpTime, 1, -1 do
task.wait(1)
status.Value = "Split up..("..x..")"
end
cloening:Destroy()
local CLONING = game.Workspace.KillStartGame:Clone()
CLONING.Parent = game.Workspace
CLONING.Position = Vector3.new(-386.566, 22.128, 23.452)
CLONING.Size = Vector3.new(290.586, 208.991, 281.654)
task.wait(1)
CLONING:Destroy()
end
for i = roundLength, 1, -1 do
for x, players in pairs(plrs) do
if players then
character = players.Character
if not character then
table.remove(plrs, x)
else
if character:FindFirstChild("GameTag") then
print(players.Name.." are still in game!")
else
table.remove(plrs,x)
print(players.Name.." are removed from the game")
end
end
else
table.remove(plrs,x)
print(players.Name.. " has been removed from the game!")
end
end
status.Value = "Game ends in ".. i .. " seconds"
if #player == 1 then
if #plrs == 0 then
status.Value = "All players has died"
break
elseif i == 0 then
status.Value = "Time's up!"
break
end
elseif #player >= 2 then
if #plrs == 1 then
status.Value = "Winner : ".. plrs[1].Name.."!"
plrs[1].Money.Value += 20
plrs[1].Exp.Value += 50
plrs[1].leaderstats.Wins.Value += 1
break
elseif i == 0 then
status.Value = "Time's up!"
break
elseif #plrs == 0 then
status.Value = "All players has died"
break
end
end
task.wait(1)
end
for i = 1, #player do
if player[i].afkMode.Value == true then
else
local char = player[i].Character
char:FindFirstChild("HumanoidRootPart").CFrame = SpawnLocation1.CFrame + Vector3.new(0,2,0)
end
end
for i, players in pairs(game.Players:GetPlayers()) do
Char = players.Character
if not Char then
else
if Char:FindFirstChild("GameTag") then
Char.GameTag:Destroy()
end
end
end
if game.Workspace:FindFirstChild("Old Roblox") then
game.Workspace["Old Roblox"]:Destroy()
end
if game.Workspace:FindFirstChild("Lost Arena") then
game.Workspace["Lost Arena"]:Destroy()
end
if game.Workspace:FindFirstChild("Season Memory") then
game.Workspace["Season Memory"]:Destroy()
end
if game.Workspace:FindFirstChild("Zoyna Grass") then
game.Workspace["Zoyna Grass"]:Destroy()
end
if game.Workspace:FindFirstChild("Sky Temple") then
game.Workspace["Sky Temple"]:Destroy()
end
end