Let say I have a Folder named ‘Bricks’ and it has 5,000 models that all have a random number of parts in (around 10 atleast in each). And i keep calling :GetChildren In a loop. Would that lag the game or not?
local RunService = game:GetService("RunService")
local Bricks = workspace.Bricks
for Count, Object in pairs(Bricks:GetChildren) do
--blah blah blah
Depending on the number of objects and what you’re using the loop for, that would absolutely start having a performance impact since you’re doing that every frame
I don’t know when you will ever need 5000 models, but nonetheless your game is gonna lag anyway since it has to load the models, espacially if you use RunService and looping it all the time
Why do you loop through all the children in the first place?
to move them. i just need to know if this part would lag it.
Why do you have to move them, what is the purpose?
I am asking this, because you might be approaching this the wrong way.
its for a tower defence game. Moving it on the client for a syncer
You should try and minimize the amount of indexes in a loop whenever possible, having a parent model that consists of multiple models helps.
So I should parent multiple enemies into one model, then reference them through there?
Yes. In theory if you parent all 5000 models into a parent model, it is 1 movement instead of 5000. - That is how models are calculated as far as I am aware. This is also why it is way less laggy, when you try to move 1 model consisting of 5000 parts, instead of the 5000 parts directly.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.