I am trying to make a NPC queueing system and have come across a problem, the way it works is it will at random take a till out of the folder and go to it, (if the till is being used it will take it out of the folder so other NPC’s cannot go to it) Although there comes a point where there are no tills left in the folder and an error will be produced instead, is there a way to wait until there is something in the folder?
if #Folder:GetChildren() == 0 then
repeat
wait(2)
until #Folder:GetChildren() ~= 0 do
end
else
--NPC Will move normally
#folder does not give you the amount of instances inside the folder, in your case “folder” is an instance, but you can’t just get the lenght of an instance. What you meant was probably “#folder:GetChildren()” this will work since “folder:GetChildren()” returns a table and by putting a hashtag (#) in front of it, you will get a number (number of contents) returned. Your script would also crash besides of that, you forgot to add in a “wait()” or better a “game[“Run Service”].Heartbeat:Wait()”.
This is probably the most performant and clean method. You should try that.
This is not what he meant, your script is just printing the name of new added children to a folder. You are just connecting an event and not waiting for one.