How to check if a folder is empty

I’m trying to make a bowling game where the pins will respawn every time all the pins are knocked out, and for this I have a folder containing all the pins. I wrote this code but it’s not working properly.

while true do
	clonePins(4)
	repeat 
		task.wait(0.05) 
		local children = game.Workspace.pins:GetChildren()
	until children == {}
end

btw I’m still a noob at scripting, so I’m probably just making a stupid mistake.

local Folder = -- Folder here
print(#Folder:GetChildren()) -- will print the amount of children in the folder

if #Folder:GetChildren() == 0 then
    print("Folder is empty")
end
2 Likes