How to make a for loop that does something for every item in a folder with a certain word in it?

How to make a for loop that does something for every item in a folder with a certain word in it?

1 Like

I would use for i, v in pairs to get all of the items in the folder and then check what the name of v (the item) is using an if statement.

2 Likes

how would I check if v.Name has a certain word in it

1 Like

You can loop through every item in the folder by using GetDescendants or GetChildren (depending on the use case). You can then use string.find on the name of each object and see if it matches:

for _, Item in ipairs(Folder:GetChildren()) do --> Getting folder items
    if string.find(Item.Name, stringHere) do --> Matching string
        --> do something
    end
end
2 Likes