Hi im trying to make the round system infinitely repeat but i cant do it here it the code. Here is the code.
Thanks if u wanna help!
wait(0.2)
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local Map = script.Map
local LobbySpawn = game.Workspace.SpawnLocation
local SeekerRealeased = script.SeekerRealeased
local AlivePlayers = {}
local Seekerplayer = nil
local CanStart = script.CanStart
local CanTag = false
local Table_1 = {roundLength = 5, seekerlength = 10, intermissionLength = 10}
local Table_2 = {
Others = {
currentRoundLength = 0;
GameEnded = false;
}
}
task.spawn(function()
while wait(4) do---
if #game.Players:GetPlayers() >= 2 then
CanStart.Value = true
else
CanStart.Value = false
end
end
end)
local GameSpawn = game:GetService("Workspace"):WaitForChild("Maps"):WaitForChild(Map.Value).PlayerSpawn
local function roundTimer()
for i = Table_1["intermissionLength"], 1, -1 do
InRound.Value = false
task.wait(1)
Status.Value = "Intermission: "..i.. " seconds left!"
end
for i = Table_1["seekerlength"], 1, -1 do
InRound.Value = true
task.wait(1)
Status.Value = "The seeker will be realeased in: "..i.. " seconds left!"
end
for i = Table_1["roundLength"], 1, -1 do
InRound.Value = true
SeekerRealeased.Value = true
task.wait(1)
Status.Value = "The games has: "..i.. " seconds left!"
Table_2["Others"]["currentRoundLength"] = i
end
task.wait(2)
if Table_2["Others"]["GameEnded"] == true then
return
end
end
print(CanStart.Value)
print(#game.Players:GetPlayers())
CanStart.Changed:Connect(function()
if CanStart.Value == true then
spawn(roundTimer)
InRound.Changed:Connect(function()
wait(1)
if InRound.Value == true then
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char:WaitForChild("HumanoidRootPart").CFrame = GameSpawn.CFrame + Vector3.new(0 , 3 , 0)
local randomNum = math.random(1,#game.Players:GetPlayers())
for i,v in pairs(game.Players:GetPlayers()) do
print(i)
v.CameraMaxZoomDistance = 8
table.insert(AlivePlayers,i,v.Name)
if i == randomNum then
v:AddTag("Seeker")
Seekerplayer = v
table.remove(AlivePlayers,i)
Seekerplayer.Character.HumanoidRootPart.CFrame = game:GetService("Workspace"):WaitForChild("SeekerBox"):WaitForChild("Tppart").CFrame + Vector3.new(0,5,0)
SeekerRealeased.Changed:Connect(function()
if SeekerRealeased.Value == true then
if player:HasTag("Hider") then
char:WaitForChild("HumanoidRootPart").CFrame = GameSpawn.CFrame + Vector3.new(0 , 3 , 0)
end
CanTag = true
Table_2["Others"]["GameEnded"] = false
Seekerplayer.Character:WaitForChild("HumanoidRootPart").CFrame = game:GetService("Workspace"):WaitForChild("Maps"):WaitForChild(Map.Value):WaitForChild("SeekerSpawn").CFrame+ Vector3.new(0,5,0)
Seekerplayer.CanTag.Value = true
end
end)
else
v:AddTag("Hider")
end
end
end
else
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char:WaitForChild("HumanoidRootPart").CFrame = LobbySpawn.CFrame + Vector3.new(0 , 3 , 0)
end
SeekerRealeased.Value = false
CanStart = false
CanTag = false
Seekerplayer.CanTag.Value = false
end
end)
else
Status.Value = "Not enough players ("..#game.Players:GetPlayers()..")"
end
end)
task.spawn(function()
while wait(1) do
if Table_2["Others"]["GameEnded"] == true then
spawn(roundTimer)
end
end
end)
task.spawn(function()
while Table_2["Others"]["currentRoundLength"] <= 1 and Table_2["Others"]["GameEnded"] == false and InRound == true do
Table_2["Others"]["GameEnded"] = true
for i,Name in pairs(AlivePlayers) do
if game:GetService("Players"):FindFirstChild(Name) then
game:GetService("Players"):FindFirstChild(Name).leaderstats.Wins.Value += 1
end
end
end
end)
print(Table_2["Others"]["currentRoundLength"])
print(Table_2["Others"]["GameEnded"])
print(#AlivePlayers)
task.spawn(function()
while #AlivePlayers < 1 and InRound.Value == true do
Status.Value = "Seeker Won!"
Seekerplayer:WaitForChild("leaderstats").Wins.Value += 1
end
end)
while wait(2) do
for _, obj in pairs(workspace:GetChildren()) do
if obj:FindFirstChild("Humanoid") and obj:FindFirstChild("HumanoidRootPart") then
local HiderTorso = obj:FindFirstChild("UpperTorso")
HiderTorso.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
print(hit.Parent)
local SeekerChar = hit.Parent
local HiderChar = obj
local SeekerPlr = game.Players:GetPlayerFromCharacter(SeekerChar)
local HiderPlr = game.Players:GetPlayerFromCharacter(HiderChar)
if HiderPlr then
print(HiderPlr)
print(SeekerPlr)
if HiderPlr:HasTag("Hider") and SeekerPlr:HasTag("Seeker") and CanTag == true and SeekerPlr.CanTag.Value == true then
game:GetService("ReplicatedStorage").Remotes:WaitForChild("FireGUI"):FireAllClients(HiderPlr.DisplayName)
HiderTorso.CFrame = LobbySpawn.CFrame + Vector3.new(0,5,0)
for i,v in pairs(AlivePlayers) do
if v.Name == HiderPlr.Name then
table.remove(AlivePlayers,i)
end
end
end
end
end
end)
end
end
end