hello. i got this code and i want it to break if all children of the ROOMS_FOLDER got the value in it.
how would i do so?
while true do
for a,b in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
if not b:FindFirstChild("WeWentTroughThisAlready") then
local GoneTroughVal = Instance.new("BoolValue")
GoneTroughVal.Parent = b
GoneTroughVal.Name = "WeWentTroughThisAlready"
if b:FindFirstChild("CHASE_NODES") then
for c,d in ipairs(b.CHASE_NODES:GetChildren()) do
local anglePart = d
if anglePart then
game.TweenService:Create(Cloned_Rush,TweenInfo.new(script.ENEMY_SPEED.Value,Enum.EasingStyle.Linear),{CFrame = anglePart.CFrame * CFrame.new(0,0,0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
else
end
end
end
end
while true do
local allChildrenProcessed = true
for _, room in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
if not room:FindFirstChild("WeWentTroughThisAlready") then
allChildrenProcessed = false
local GoneTroughVal = Instance.new("BoolValue")
GoneTroughVal.Parent = room
GoneTroughVal.Name = "WeWentTroughThisAlready"
if room:FindFirstChild("CHASE_NODES") then
for _, node in ipairs(room.CHASE_NODES:GetChildren()) do
local anglePart = node
if anglePart then
game.TweenService:Create(Cloned_Rush, TweenInfo.new(script.ENEMY_SPEED.Value, Enum.EasingStyle.Linear), {CFrame = anglePart.CFrame * CFrame.new(0, 0, 0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
end
end
end
if allChildrenProcessed then
break
end
end
The break function will fully stop the loop if all players were processed.
while true do
local allChildrenProcessed = true
for _, room in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
if not room:FindFirstChild("WeWentTroughThisAlready") then
allChildrenProcessed = false
local GoneTroughVal = Instance.new("BoolValue")
GoneTroughVal.Parent = room
GoneTroughVal.Name = "WeWentTroughThisAlready"
if room:FindFirstChild("CHASE_NODES") then
for _, node in ipairs(room.CHASE_NODES:GetChildren()) do
local anglePart = node
if anglePart then
game.TweenService:Create(Cloned_Rush, TweenInfo.new(script.ENEMY_SPEED.Value, Enum.EasingStyle.Linear), {CFrame = anglePart.CFrame * CFrame.new(0, 0, 0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
end
end
end
if allChildrenProcessed then
break
end
end
local allChildrenProcessed = true
while true do
for _, room in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
if not room:FindFirstChild("WeWentTroughThisAlready") then
allChildrenProcessed = false
local GoneTroughVal = Instance.new("BoolValue")
GoneTroughVal.Parent = room
GoneTroughVal.Name = "WeWentTroughThisAlready"
if room:FindFirstChild("CHASE_NODES") then
for _, node in ipairs(room.CHASE_NODES:GetChildren()) do
local anglePart = node
if anglePart then
game.TweenService:Create(Cloned_Rush, TweenInfo.new(script.ENEMY_SPEED.Value, Enum.EasingStyle.Linear), {CFrame = anglePart.CFrame * CFrame.new(0, 0, 0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
end
end
end
if allChildrenProcessed then
break
end
end
maybe try and put the value on the outfit of the loop
local allChildrenProcessed = true
local values = {}
while true do
for _, room in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
if not room:FindFirstChild("WeWentTroughThisAlready") then
allChildrenProcessed = false
local GoneTroughVal = Instance.new("BoolValue")
GoneTroughVal.Parent = room
GoneTroughVal.Name = "WeWentTroughThisAlready"
table.insert(values, GoneTroughVal)
if room:FindFirstChild("CHASE_NODES") then
for _, node in ipairs(room.CHASE_NODES:GetChildren()) do
local anglePart = node
if anglePart then
game.TweenService:Create(Cloned_Rush, TweenInfo.new(script.ENEMY_SPEED.Value, Enum.EasingStyle.Linear), {CFrame = anglePart.CFrame * CFrame.new(0, 0, 0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
end
end
end
if allChildrenProcessed then
break
end
end
for _, value in values do
value:Destroy()
value = nil
end
values = nil