FindFirstChildThatAreNot

Im trying to get an object of a parent that is NOT named something. For example:

if workspace.[ALL FOLDERS NOT NAMED ExcludeMe]:FindFirstChild'Model' and not workspace.ExcludeMe:FindFirstChild'Model'  then
print'yay'
end

Any help on how to do that efficiently, such as with a function?

You are probably trying to do something like iterating over the instance’s children NOT named something

for _, child in instance:GetChildren() do
	if child.Name == "something" then
		continue -- skip this iteration
	end

	-- do something with the instance NOT named such way
end

I’m trying to check if the child (same name in each folder) of every folder not excluded is present, and if the one folder that is excluded doesn’t have said child is true.

Better off telling us what this will achieve

Checking if all players except one have a certain tool in their backpack, and if the specified player doesnt have it in their backpack, and doing something if that is true. Sorry, didnt mean to create the xy problem and figured this may be simpler.

I made a silly mistake, use this instead I edited it.

Ill use this and alter it a bit but this should help, ill come back here if I seem to have problem, thanks!

This is better

local searchName = ""
local allContainChildWithName = true

for _, folder in workspace.Folder:GetChildren() do
	if not folder:FindFirstChild(searchName) then
		allContainChildWithName = false
		break
	end
end

if allContainChildWithName then
	print("All folders have a child named that")
else
	print("One folder doesnt have a child named that")
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.