For i,v pairs Loop Ignore certain things in a folder?

Hi there! Is there anyway for a for i,v pairs loop to ignore certain things in a folder? Ive been trying to make it where the for i,v pairs loop ignore like a bunch of parts with a same name and ignore the others that arent the same name!
Im not good at coding at all!

Screenshot (75)

So I want the for i,v loop to ignore the parts that say “Part” and not ignore the other parts that say “Close”! Ive made a blacklist script before and the script dosent function at all! Can somebody please help me with this?

1 Like

This is possible by making a if statement that checks the name of the part.

Well I tryed that but I want it to print how many Close parts there is in there

if v.Name == ‘Close’ then
print(#workspace.FolderWork:GetChildren())
end

Could we see the entire script?

if part.Name ~= "Part" then
      -- code here
end

Returns false if the part is named “Part”

(and yes, this goes inside the loop before the actual code runs)

> while task.wait() do
> 	local children  = workspace.FolderWork:GetChildren()
> 	for i,v in pairs(children) do
> 		if v.Name ~= "Part" then
> 			print(#workspace.FolderWork:GetChildren())
> 		end
> 	end
> end
local function GetChildrenOfName(object, name)
	local objects = {}
	for _, obj in pairs(object:GetChildren()) do
		if obj.Name == name then
			table.insert(objects, obj)
		end
	end
	return objects
end

this script does not need a local function in it
also I want the script to know how many number of parts that are called ''Close" in it

It will help you iterate only Close objects, and also let you know how many there are.

local ignored = {"Part"}
for i,v in ipairs(folder:GetChildren()) do
if not table.find(ignored,v.Name) then
print(v.Name.. "is not ignored!")
else
print(v.name.. "is ignored.")
end
end

This does help but I want a script to like print how many there is!

like how many un ignored stuff there is?

keep a counter, and everytime you find the part you want, increment it by one

local ignored = {"Part"}
local yo = 0
for i,v in ipairs(folder:GetChildren()) do
if not table.find(ignored,v.Name) then
print(v.Name.. "is not ignored!")
yo += 1
else
print(v.name.. "is ignored.")
end
end
print(yo)

So I tryed that and it kept saying random numbers! I wanted it to say something like this!

if not table.find(ignored,v.Name) then
			print(#workspace.FolderWork:GetChildren())
		end
	end
local parts = {}
if not table.find(ignored,v.Name) then
            table.insert(parts,v)
			print(#parts)
		end
	end

So i tryed adding that but it looked like this

Screenshot (76)

Keep in mind this is a While Task.Wait() Do Script
Also there is 8 parts in the folder

local ignored = {"Part"}
local parts = {'Close'}
while task.wait() do
for i,v in ipairs(workspace.FolderWork:GetChildren()) do
		if not table.find(ignored,v.Name) then
			table.insert(parts,v)
			print(#parts)
		end
	end
end

thats because you are repeat adding the part.

local parts = {}
if not table.find(ignored,v.Name) and not table.find(parts,v) then
            table.insert(parts,v)
			print(#parts)
		end
	end

So in the parts table do I add “Part”?

Parts table is basically the parts that it found and added, Ignored is a table that ignores the detected parts with the certain names.