So I’m making a timer that runs during every wave. And I want to break it when there’s no children left in the folder. The problem is it doesn’t stop it when the condition is met. Tried doing return too but it still didn’t work.
local wave = workspace.Info.Wave
local TFM = require(game.ServerScriptService.Main.TFM)
wave.Changed:Connect(function()
if wave ~= 1 or wave ~= 2 or wave ~= 3 or wave ~= 4 or wave ~= 5 or wave ~= 6 or wave ~= 7 or wave ~= 8 or wave ~= 9 then
for i=60, 0, -1 do
local timer = TFM:Convert(i, "Default", false)
workspace.Info.Countdown.Value = timer
task.wait(1)
if workspace.InGameMobs:GetChildren() == 0 then
break
end
end
elseif wave ~= 10 then
for i=90, 0, -1 do
local timer = TFM:Convert(i, "Default", false)
workspace.Info.Countdown.Value = timer
task.wait(1)
if workspace.InGameMobs:GetChildren() == 0 then
break
end
end
end
end)
Use the # to get the number of children. I believe that is the issue
local wave = workspace.Info.Wave
local TFM = require(game.ServerScriptService.Main.TFM)
wave.Changed:Connect(function()
if wave ~= 1 or wave ~= 2 or wave ~= 3 or wave ~= 4 or wave ~= 5 or wave ~= 6 or wave ~= 7 or wave ~= 8 or wave ~= 9 then
for i=60, 0, -1 do
local timer = TFM:Convert(i, "Default", false)
workspace.Info.Countdown.Value = timer
task.wait(1)
if #workspace.InGameMobs:GetChildren() == 0 then
break
end
end
elseif wave ~= 10 then
for i=90, 0, -1 do
local timer = TFM:Convert(i, "Default", false)
workspace.Info.Countdown.Value = timer
task.wait(1)
if #workspace.InGameMobs:GetChildren() == 0 then
break
end
end
end
end)
Try #workspace.InGameMobs:GetChildren() this gets the length of table
oh @BabyNinjaTime was quicker
1 Like
Use Disconnect to stop events from triggering.
Sorry, I should get some sleep. I’m not even reading topic titles properly now.
1 Like
Thanks for the help! It worked!
1 Like