Is looping through real objects laggier than looping through strings or values?

I just wanted to know which one would cause more lag.

for i,v in ipairs(folder:GetChildren()) do

end

or

local container = {} -- stores important objects

for i,v in pairs(container) do

end

I’m not sure what the difference is or what you mean by “important objects” in comparison to the folder’s children, but if there is a difference, it’s definitely negligible. What matters more, if anything, is the size of the array/dictionary and the actual operation that the loop is repeatedly doing.

Like storing important objects only instead of storing the whole character:

local container = {}

table.insert(container, {Root = root})

for i,v in pairs(container) do
	
end

the only difference here would be from calling :GetChildren()

1 Like