Anti Virus Stack Help

I have this code:

function checkMalCode() 
    for k,j in pairs(scanZone) do
        for _,desc in pairs(scanZone) do
            for i,v in pairs(desc:GetDescendants()) do
        if v:IsA("LuaSourceContainer") then
            
            for i,word in pairs(virusCode) do
        if v.Source:lower():find(word:lower()) then
                             
           
    local fullName = v:GetFullName()
      print("Found something in "..fullName.."!") 
                            
    break
        end

            end
                    
            end
                
    end
        end
    end
end

image

and as the picture provided shows, it spams the output with how many times it found the word, not if it is found. I have a break statement so idk what im doing wrong, but I only want it to say once that it found something. How do I achieve this?

You would need to break all of the for is when you found it, you’re only breaking one.

1 Like

Try this:

function checkMalCode() 
	for k,j in pairs(scanZone) do
		for _,desc in pairs(scanZone) do
			for i,v in pairs(desc:GetDescendants()) do
				if v:IsA("LuaSourceContainer") then
					for i,word in pairs(virusCode) do
						if v.Source:lower():find(word:lower()) then
							local fullName = v:GetFullName()
							print("Found something in "..fullName.."!") 

							return
						end
					end
				end
			end
		end
	end
end

This might’ve worked, but I already solved it with @Pseudoisochromatic answer. Thanks anyways!