Retrieving objects with a certain attribute

Is there any way to retrieve an object with a certain attribute to it? For example, if I had a list of items, all with the attribute “Code”, is there any way to retrieve the object with the Attribute(“Code”) equal to a certain value? I’d rather not use loops as they’re far too slow, but I cannot find any method like FindFirstChild() that works for attributes.

if obj:GetAttribute("Code") == value then

That would require a loop, which I’ve tried, but is quite slow. Is there any method of fetching the object without looping through every one to find it?

1 Like

are you trying to get all of which objects in your game that has the “Code” attribute?

No, I’m trying to get a single part from a folder that has the attribute “Code” equal to a certain value. I am asking to see if there is any method such as (an example) folder:FindFirstChildWithAttribute(“Code”, “1234”) that could return to me the object without having to loop through it.

no theres no such thing, youd have to create a loop for something like that

find first child is like a builtin for loop checking if something is what is looking for

1 Like

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