Hello Developers!
So I’m making a minigame, it was all working until I put in another minigame. The issue is the timer is not working because the repeat until is not running at all
there is also no error at all
CODE:
local s = script.Stat
local maps = game.ReplicatedStorage.Maps:GetChildren()
local rand = math.random(1, #maps)
local map = maps[rand]:Clone()
t = 0
while true do
t = 15
repeat
t = t-1
s.Value = "Intermission "..t
wait(1)
until t == 0
s.Value = "Game Starting!"
wait(1)
map.Parent = workspace
s.Value = "We'll be playing "..map.Name
wait(3)
local players = game.Players:GetChildren()
for i = 1,#players do
if players[i].Character ~= nil then
local spawnLocation = math.random(1,#workspace.Spawns:GetChildren())
local spawnLocation2 = math.random(1,#workspace.Spawns2:GetChildren())
if map.Name == "Obby" then
players[i].Character:MoveTo(workspace.Spawns2:GetChildren()[spawnLocation2].Position)
players[i].Character.Parent = workspace.Ingame
else
if map.Name == "Mountain Over Flow!" then
players[i].Character:MoveTo(workspace.Spawns2:GetChildren()[spawnLocation].Position)
players[i].Character.Parent = workspace.Ingame
else
players[i].Character:MoveTo(workspace.Spawns:GetChildren()[spawnLocation].Position)
players[i].Character.Parent = workspace.Ingame
end
end
end
end
end
local roundLength = 120
local canWin = true
local roundType = ""
if map:FindFirstChild("Obby") then
roundType = "Obby"
map.Endpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and canWin == true then
canWin = false
s.Value = hit.Parent.Name.." has won!"
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value +1
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +10
end
end)
elseif map:FindFirstChild("Snowball") then
roundType = "Snowball"
local children = workspace.Ingame:GetChildren()
for i = 1,#children do
map:FindFirstChildWhichIsA("Tool"):Clone().Parent = children[i]
end
map:FindFirstChildWhichIsA("Tool"):Destroy()
end
if map:FindFirstChild("Mountain Over Flow!") then
roundType = "Mountain Over Flow!"
map.Endpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and canWin == true then
canWin = false
s.Value = hit.Parent.Name.." has won!"
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value +1
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +10
end
end)
end
repeat
roundLength = roundLength -1
s.Value = "Time Left: "..roundLength
wait(1)
until roundLength == 0 or canWin == false or #workspace.Ingame:GetChildren() == 0 or (#workspace.Ingame:GetChildren() == 1 and roundType == "Snowball")
if #workspace.Ingame:GetChildren() == 1 and roundType == "Snowball" then
local char = workspace.Ingame:FindFirstChildWhichIsA("Model")
s.Value = char.Name.. " has won"
local plr = game.Players:GetPlayerFromCharacter(char)
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value +1
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +10
end
wait(.5)
map:Destroy()
local players = game.Players:GetChildren()
for i = 1,#players do
if players[i].Character ~= nil then
players[i]:LoadCharacter()
end
end
THE CODE THAT IS NOT RUNNING
repeat
roundLength = roundLength -1
s.Value = "Time Left: "..roundLength
wait(1)
until roundLength == 0 or canWin == false or #workspace.Ingame:GetChildren() == 0 or (#workspace.Ingame:GetChildren() == 1 and roundType == "Snowball")
please note before i added the minigame everything was working.
https://devforum.roblox.com/t/repeat-untill-not-running/1569967 is my post on the dev forum

2 comments
You shoud probably use <= 0 and not == 0 as run time can cause thigns to double up and the value not getting a chance to get to 0
I usually use ol' reliable:
Make a variable.
Make it so unless the variable is at a certain value, keep adding. when it reaches that, reset. i would give code, but i'm new to this.