How can I find a child with a specific property?

I have the .Touched listener on several parts and they all are corresponding to other parts in studio with the same colour, however an ObjectValue won’t work here as multiple parts will share that same colour, I am attempting to select the corresponding parts that are of that property, how can I achieve this, and is it possible without a for i,v loop?
image

You could use CollectionService and apply a tag to corresponding pairs of those obby parts, but I don’t see the harm in using iteration here. Is there a reason you don’t want to use a for loop?

im just so used to writing in JavaScript now and using stuff like .some that I don’t really like iteration

.some internally uses iteration to work. The simplest way to look for a property would simply be to use a for loop, like such.

local expectedProperty
for _, v in pairs(OBBYPARTS_DIRECTORY:GetChildren()) do
    if v.PROPERTY == expectedProperty then
         -- do your thing here
    end
end
1 Like

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