As in I want to find the first child from a folder of BoolValues that has a value of True. Would there be an easier method compared to looping through the folder until you find one?
✓ ANSWER ACCEPTED
Is there a way to do FindFirstChild that searches for the first child with a given property?
2 answers
✓ Accepted answer
I'm not sure what you mean by an easier method, a loop in this case is quite simple (a mere 7 lines):
local boolValue
for _, value in next, folder:GetChildren() do
if value.Value then
boolValue = value
break
end
end
You could always use a onchanged - rather then looping.
So every time one of the bool values change - you do whatever you need to do.
So like - an if statement in a onchanged function that checks if the bool value is true.
1 comment
0
The problem with that is the script I'm making can't use a OnChanged event, it needs to know at that point in time where the first child with a certain value is. I'm just curious about whether you can do it without a loop or not.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
As wonderful as that is, you'll need to consider that putting value.Value can break the script. Instead, change the if statement to
if value:IsA("BoolValue") and value.Value thenAs long as there is nothing in the folder other than BoolValues then it makes no difference and It is unnecessary to complete that check