Since I don’t want it to restart a loop
But it is okay if it just goes through the not done Once
The loop stops when the queue is over.
So what will happen if something gets added to the folder
If you comment/remove the break line it should keep looping and either say nil
if the queue is currently empty or give an element. Else if you don’t comment that line it stops when the queue is empty, and if it’s empty on the game start it never runs(however you can add delay before the loop so the loop doesn’t start until the instances are there).
It will stop, but you could keep it running if you removed that one line.
Ok, so how it works is I have a folder with rooms. And in each room is a folder with weird points. And I wanted to go smoothly through all rooms even if one gets added
Without messing up the numerizing.
How am I supposed to put that into my screen
I mean can I come back to you if it does not work
So what if all the rooms in the folder have been went through. Do you still want the entity to keep going?
If the room was edit while the energy is going down yet
If the room was added while the entity was on the way then yes
And if all the room gets gone through and there are no rooms to go, the entity wont follow any rooms that might be added?
Okay, so imagine the entity is exactly as fast as the player.
And if it is exactly behind him, then the loop needs to go infinite since the entity cannot reach the end of a room before a new one gets added, why the loop is running
So I want the entity to hit the finished room before another one gets added. Then I wanted to try and get to that one
i’m not sure if you would include this as “restarting the loop” but recursion is the best option:
local function recursive_loop(folder, last_index)
local folder_children = folder:GetChildren()
local new_index = nil
for i = last_index,#folder_children,1 do
task.wait(1)
print(folder_children[i])
new_index = i + 1
end
if #folder:GetChildren() > #folder_children then
return recursive_loop(folder, new_index)
end
end
coroutine.resume(coroutine.create(function()
recursive_loop(workspace.Folder, 1)
end))
local Part = Instance.new("Part")
Part.Parent = workspace.Folder
You know so I do not want anyone to can hide from it
So what exactly is the Miss script doing