Will looping through a folder with TONS of objects cause lag?

I might be stupid for asking this, but I am making an RPG, which means I will store lots of weapons/armor whatever items inside a folder. And I use alot of for i, v in pairs for checking.

for i, v in pairs(Folder:GetChildren()) do
    
end

I was wondering, if the Folder had more than 5,000 items, will it cause lag if I looped through all of it to get one item?

1 Like

it will lag if you write something that client needs to render something inside that loop
for example, if it just does math calculations ( in loop ) then it wont lag.
but if loop makes a new instance or something like that, then it will lag very much

1 Like

i’m using it rn to make sure that an item exists in a player’s inventory or if the item even exists

thanks!