Part.name problems

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I dont understand why this doesnt work, it only detects 2 or 3 of the names before printing “done”
  2. What is the issue? Include screenshots / videos if possible!
    asfver
    zFadv
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,math.huge)) do
		if Part:FindFirstChild("Detect") then
			if game.ReplicatedStorage.QuestValues.PlushQuest.Value == true then
				print(Part.Name)
				if Part.Name == ("plushj1" and "plushj2" and "plushj3" and "plushj4" and "plushj5") then
					print("DONE")
				end
			end
		end
	end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

This isn’t the right way to check for multiple possible conditions. You would need to instead do

if Part.Name == "plushj1" or Part.Name == "plushj2" or ... then
    print("DONE")
end

This gets pretty ugly though, so perhaps you could instead create a table to search from, so

local search = {"plushj1", "plushj2", ...}
if table.find(search, Part.Name) then
    print("DONE")
end

What your currently doing instead is essentially a stacked ternary operator (var = condition and A or B), and since a string is truthy, only your last condition will survive (“plushj5”) which is why only that one is working.

i dont want to find one of the names listed, i want to find all, because it is detecting multiple parts, i want to make sure that it prints after it detects all of those part names

Oh, well that does get a bit complicated. I think that it should work with something like this:

local search = {"plushj1", "plushj2", "plushj3", "plushj4", "plushj5"}

local found = {}
for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,math.huge)) do
	if Part:FindFirstChild("Detect") then
		if game.ReplicatedStorage.QuestValues.PlushQuest.Value == true then
			if not table.find(found, Part.Name) and table.find(search, Part.Name) then
				table.insert(found, Part.Name)
			end
		end
	end
end

if #found == #search then
	print("DONE")
end

For each iteration of the loop, you only have one part instance found within the region3, so you cannot check for every condition at once. Instead, you can only check for the singular condition that this part should have been detected.

The code above has a static list ,search, of the part names to find to be used as reference. Every time you try to detect the wanted parts, create a new empty list found that will hold the parts that you found. If you found a part you need, then add this part name to the list. To avoid duplicates, before adding make sure that it has already not been added (this is very crucial for the last part)

Since no duplicates can occur, you can be certain that you’ve found all of the required parts if the length of found and search are the same (that is of course if search does not have any duplicates itself!)

OK thanks i kinda understand how it works.

SO its basically detecting what needs to be found and what is there, and if they match up, with names, then it prints done, and the “#found == #search” checks if the names mach what is found