Hello, I am working on a game with a round system and I don’t know what I did but when I tested it and the intermission timer hit 0 it would immediately go back to 20 and not start the round.
I have no idea what to do and if somebody could help me I would be happy.
here is my code,
local roundlong = 300
local intermisshion = 20
local inround = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local endpart = game.Workspace.Finish
local keytouched = endpart.KeyGotTouched
local lobby = game.Workspace.LobbySpawn
local gamespawn = game.Workspace.PlayZoneSpawn
local monsterspawn = game.Workspace.MonsterSpawn
local key = game.Workspace.KEY1
local playersingame = game.ReplicatedStorage.PlayersinGame
local playyers = game:GetService("Players")
local explosin = game.Workspace.Explosion
local explsionsound = game.Workspace.explosionSound
local plrs = game.Players
local explodeplayed = true
playyers.PlayerAdded:Connect(function(Player)
local inround = Instance.new("BoolValue", Player)
inround.Name = "inround"
end)
randompos = {Vector3.new(-46, 6, 940), Vector3.new(-22.561, 5.899, 803.9370), Vector3.new(244.186, 5.899, 644.847), Vector3.new(169.481, 5.699, 865.127), Vector3.new(120.524, 6.799, 824.427), Vector3.new(106.634, 7.699, 862.727), Vector3.new(105.734, 6.499, 962.327)}
inround.Changed:Connect(function()
if inround.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.UpperTorso.CFrame = gamespawn.CFrame
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobby.CFrame
end
end
end)
local function roundTimer()
while wait() do
for i = intermisshion, 1, -1 do
game.Lighting.FogEnd = 999999
if explodeplayed == false then
explsionsound:Play()
explosin.Transparency = .5
explodeplayed = true
end
wait(1)
inround.Value = false
keytouched.Value = false
key.Position = randompos[math.random(1, #randompos)]
status.Value = "Intermission: ".. i .." seconds left!"
end
end
for i, plr in pairs(plrs:GetChildren()) do
local monster = game.Players:GetChildren() [math.random(1, #game.Players:GetChildren())]
local monsterchar = monster.Character
local uiwait = 5
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #game.Players:GetChildren()
monsterchar.Humanoid.MaxHealth = amountonteam
monsterchar.Humanoid.Health = amountonteam
monsterchar.HumanoidRootPart.Position = Vector3.new(339.955, 5.284, 895.927)
monster.PlayerGui.Monster.Frame.Visible = true
if plr == monster then
plr.Team = game:GetService("Teams")["Monster"]
else
plr.Team = game:GetService("Teams")["Playing"]
end
for i = roundlong, 1, -1 do
game.Lighting.FogEnd = 50
inround.Value = true
explosin.Transparency = 1
explodeplayed = false
wait(1)
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #playersOnTeam
local playersOnTeamMonster = game:GetService("Teams")["Monster"]:GetPlayers()
local amountonteamMonster = #playersOnTeamMonster
print(amountonteam)
if amountonteam <= 0 or amountonteamMonster <= 0 then
print("cools")
break
end
status.Value = "Game: ".. i .." seconds left!"
end
end
end
spawn(roundTimer)
local roundlong = 300
local intermisshion = 20
local inround = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local endpart = game.Workspace.Finish
local keytouched = endpart.KeyGotTouched
local lobby = game.Workspace.LobbySpawn
local gamespawn = game.Workspace.PlayZoneSpawn
local monsterspawn = game.Workspace.MonsterSpawn
local key = game.Workspace.KEY1
local playersingame = game.ReplicatedStorage.PlayersinGame
local playyers = game:GetService("Players")
local explosin = game.Workspace.Explosion
local explsionsound = game.Workspace.explosionSound
local plrs = game.Players
local explodeplayed = true
playyers.PlayerAdded:Connect(function(Player)
local inround = Instance.new("BoolValue", Player)
inround.Name = "inround"
end)
randompos = {Vector3.new(-46, 6, 940), Vector3.new(-22.561, 5.899, 803.9370), Vector3.new(244.186, 5.899, 644.847), Vector3.new(169.481, 5.699, 865.127), Vector3.new(120.524, 6.799, 824.427), Vector3.new(106.634, 7.699, 862.727), Vector3.new(105.734, 6.499, 962.327)}
inround.Changed:Connect(function()
if inround.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.UpperTorso.CFrame = gamespawn.CFrame
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobby.CFrame
end
end
end)
local function roundTimer()
while wait() do
for i = intermisshion, 1, -1 do
game.Lighting.FogEnd = 999999
if explodeplayed == false then
explsionsound:Play()
explosin.Transparency = .5
explodeplayed = true
end
wait(1)
inround.Value = false
keytouched.Value = false
key.Position = randompos[math.random(1, #randompos)]
status.Value = "Intermission: ".. i .." seconds left!"
end
for i, plr in pairs(plrs:GetChildren()) do
local monster = game.Players:GetChildren() [math.random(1, #game.Players:GetChildren())]
local monsterchar = monster.Character
local uiwait = 5
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #game.Players:GetChildren()
monsterchar.Humanoid.MaxHealth = amountonteam
monsterchar.Humanoid.Health = amountonteam
monsterchar.HumanoidRootPart.Position = Vector3.new(339.955, 5.284, 895.927)
monster.PlayerGui.Monster.Frame.Visible = true
if plr == monster then
plr.Team = game:GetService("Teams")["Monster"]
else
plr.Team = game:GetService("Teams")["Playing"]
end
for i = roundlong, 1, -1 do
game.Lighting.FogEnd = 50
inround.Value = true
explosin.Transparency = 1
explodeplayed = false
wait(1)
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #playersOnTeam
local playersOnTeamMonster = game:GetService("Teams")["Monster"]:GetPlayers()
local amountonteamMonster = #playersOnTeamMonster
print(amountonteam)
if amountonteam <= 0 or amountonteamMonster <= 0 then
print("cools")
break
end
status.Value = "Game: ".. i .." seconds left!"
end
end
end
end
spawn(roundTimer)
Started rebuilding this and then looked at the while loop … Looks like it’s repeating as told to do before you get to the teleaport part. Try just removing that loop and keeping the For loop
local function roundTimer()
intermisshion = 20
for i = intermisshion, 1, -1 do
game.Lighting.FogEnd = 999999
if explodeplayed == false then
explsionsound:Play()
explosin.Transparency = .5
explodeplayed = true
end
task.wait(1)
inround.Value = false
keytouched.Value = false
key.Position = randompos[math.random(1, #randompos)]
status.Value = "Intermission: ".. i .." seconds left!"
end
for i, plr in pairs(plrs:GetChildren()) do
this one is teleports the players but is stuck at 1
local roundlong = 300
local intermisshion = 20
local inround = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local endpart = game.Workspace.Finish
local keytouched = endpart.KeyGotTouched
local lobby = game.Workspace.LobbySpawn
local gamespawn = game.Workspace.PlayZoneSpawn
local monsterspawn = game.Workspace.MonsterSpawn
local key = game.Workspace.KEY1
local playersingame = game.ReplicatedStorage.PlayersinGame
local playyers = game:GetService("Players")
local explosin = game.Workspace.Explosion
local explsionsound = game.Workspace.explosionSound
local plrs = game.Players
local explodeplayed = true
playyers.PlayerAdded:Connect(function(Player)
local inround = Instance.new("BoolValue", Player)
inround.Name = "inround"
end)
randompos = {Vector3.new(-46, 6, 940), Vector3.new(-22.561, 5.899, 803.9370), Vector3.new(244.186, 5.899, 644.847), Vector3.new(169.481, 5.699, 865.127), Vector3.new(120.524, 6.799, 824.427), Vector3.new(106.634, 7.699, 862.727), Vector3.new(105.734, 6.499, 962.327)}
inround.Changed:Connect(function()
if inround.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = gamespawn.CFrame
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobby.CFrame
end
end
end)
local function roundTimer()
for i = intermisshion, 1, -1 do
game.Lighting.FogEnd = 999999
if explodeplayed == false then
explsionsound:Play()
explosin.Transparency = .5
explodeplayed = true
end
wait(1)
inround.Value = false
keytouched.Value = false
key.Position = randompos[math.random(1, #randompos)]
status.Value = "Intermission: ".. i .." seconds left!"
end
for i, plr in pairs(plrs:GetChildren()) do
local monster = game.Players:GetChildren() [math.random(1, #game.Players:GetChildren())]
local monsterchar = monster.Character
local uiwait = 5
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #game.Players:GetChildren()
monsterchar.Humanoid.MaxHealth = amountonteam
monsterchar.Humanoid.Health = amountonteam
monsterchar.HumanoidRootPart.Position = Vector3.new(339.955, 5.284, 895.927)
if plr == monster then
--monster.PlayerGui.Monster.Frame.Visible = true
plr.Team = game:GetService("Teams")["Monster"]
else
plr.Team = game:GetService("Teams")["Playing"]
end
for i = roundlong, 1, -1 do
game.Lighting.FogEnd = 50
inround.Value = true
explosin.Transparency = 1
explodeplayed = false
wait(1)
local playersOnTeam = game:GetService("Teams")["Playing"]:GetPlayers()
local amountonteam = #playersOnTeam
local playersOnTeamMonster = game:GetService("Teams")["Monster"]:GetPlayers()
local amountonteamMonster = #playersOnTeamMonster
print(amountonteam)
if amountonteam <= 0 or amountonteamMonster <= 0 then
print("cools")
break
end
status.Value = "Game: ".. i .." seconds left!"
end
end
end
spawn(roundTimer)
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")
local inround = ReplicatedStorage.InRound
local status = ReplicatedStorage.Status
local lobby = workspace.LobbySpawn
local gamespawn = workspace.PlayZoneSpawn
local monsterspawn = workspace.MonsterSpawn
local endpart = workspace.Finish
local key = workspace.KEY1
local keytouched = endpart.KeyGotTouched
local playersingame = ReplicatedStorage.PlayersinGame
local explosin = workspace.Explosion
local explsionsound = workspace.explosionSound
local explodeplayed = true
local roundTime = 300
local intermissionTime = 20
local randompos = {
Vector3.new(-46, 6, 940),
Vector3.new(-22.561, 5.899, 803.9370),
Vector3.new(244.186, 5.899, 644.847),
Vector3.new(169.481, 5.699, 865.127),
Vector3.new(120.524, 6.799, 824.427),
Vector3.new(106.634, 7.699, 862.727),
Vector3.new(105.734, 6.499, 962.327)
}
Players.PlayerAdded:Connect(function(player)
local readyTag = Instance.new("BoolValue")
readyTag.Name = "inround"
readyTag.Parent = player
end)
inround.Changed:Connect(function()
if inround.Value == true then
for _, player in pairs(Players:GetPlayers()) do
local char = player.Character
char.HumanoidRootPart.CFrame = gamespawn.CFrame
end
else
for _, player in pairs(Players:GetPlayers()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobby.CFrame
end
end
end)
local function runRound()
while intermissionTime > 0 do
intermissionTime -= 1
Lighting.FogEnd = 999999
if explodeplayed == false then
explsionsound:Play()
explosin.Transparency = .5
explodeplayed = true
end
task.wait(1)
inround.Value = false
keytouched.Value = false
key.Position = randompos[math.random(#randompos)]
status.Value = "Intermission: ".. intermissionTime .." seconds left!"
end
intermissionTime = 20 -- resets
for _, plr in pairs(Players:GetPlayers()) do
local monster = Players:GetPlayers()[math.random(#Players:GetPlayers())]
local monsterchar = monster.Character
local amountonteam = #Players:GetPlayers()
monsterchar.Humanoid.MaxHealth = amountonteam -- no scaling?
monsterchar.Humanoid.Health = amountonteam -- no scaling?
monsterchar.HumanoidRootPart.Position = Vector3.new(339.955, 5.284, 895.927)
monster.PlayerGui.Monster.Frame.Visible = true
if plr == monster then
plr.Team = Teams["Monster"]
else
plr.Team = Teams["Playing"]
end
status.Value = "Game: ".. roundTime .." seconds left!"
end
while roundTime > 0 and (Teams["Playing"]:GetPlayers() > 0 and #Teams["Monster"]:GetPlayers() > 0) do
roundTime -= 1
Lighting.FogEnd = 50
inround.Value = true
explosin.Transparency = 1
explodeplayed = false
task.wait(1)
status.Value = "Game: ".. roundTime .." seconds left!"
end
roundTime = 300
end
while true do
runRound()
end