Currently in my game, i’ve a few optimizations made, such as things that require a loop, run off of a single loop in a script connected via module scripts.
However, I need to optimize it more as i’m going to add more features that are going to add an extra load.
At the moment i’ve a bunch of scripts that run off of collection service.
Everything that’s not in LoopTied has a touched function within a for i,v in pairs loop, Is there a way to optimize it?
Also any other ideas / tips to optimize would be helpful also, Thanks.
It’s not the loops that need optimizing, In the scripts Attach, Hydrant and Teleport, i iterate through each item with a given tag and then check if it’s been touched, I’m wondering if there’s a way to optimize that in terms to reduce threads.
EDIT: My bad, i saw i put loops in the title, my mistake
yeah, why are you using for i, v in pairs? it’s called a generic loop, and not needed here; iterate through ipairs to improve a bit on speed for several reasons.
Can you give more information on what each script does? is each script’s purpose
just to detect whether items were touched?
It is good that you modularized it like that but for developing reasons not performance reasons. In the end what matters is the amount of listeners placed, not how they are placed.
You can try to reduce collisions by using the collision filtering Collisions | Documentation - Roblox Creator Hub. This can reduce the times the .Touched function is fired which can actually increase performance.
Anyways you do not need to worry about that holding you from scaling. Unless have a lot of .Touched functions firing all the time.
I know about collision filtering but i need all of these items to be able to collide and fire the touched function, That’s why i’m using collection service. Thank you for the ideas