Search children until one with a false value is found

Hi there!
I’m trying to search through a folder of string values until the child of the value has a false value. I realise how confusing that desciption probably sounds so here’s a photo. image

“c3k” is the parent folder of the values

					for i = 1, #num do
						if num[i]:IsA("StringValue") then
							print(num[i].Name)
							if num[i].InUse.Value == false then
								print("InUseFalse"..num[i].Name)
							end
						end
					end

More a test script but it should hopefully give some better context to what I’m trying to do. Once it finds an “InUse” value that is false it needs to set the value to true and stop looking (it can’t just go onto the next one thats false and change that too since I’m trying to use it to show which numbers have been taken)

Hopefully that’s not too confusing, thanks!

this is fairly simple to do by using a break

for i = 1, #num do
	if num[i]:IsA("StringValue") then
		print(num[i].Name)
		if num[i].InUse.Value == false then
			print("InUseFalse"..num[i].Name)
            break --the for loop will stop running
		end
	end
end
1 Like
for i, stringValue in pairs(stringFolder:GetChildren()) do
    if stringValue:IsA("StringValue") then
        if stringValue.InUse.Value == false then
            return --or break
        end
    end
end