A good way to optimize SubtractAsync on multiple parts?

I’ve made a script that subtracts from many parts at once and what I’ve done is basically spam the SubtractAsync function on every part which is VERY slow. Anyone know a better way to subtract from multiple parts at once? Thanks in advance.

Since :SubtractAsync() is a yielding function, it stops execution of the whole script until it’s finished. You can shorten that process by wrapping calls in coroutines (read the article below). Each thread then runs individually and separately from each other.

However, I wouldn’t call any of this a good practice. Do you really need to do so many negatives? Not only does that affect triangle count even more, but also gives an impression that there are more efficient workarounds.

What is it that you are doing?

I`m making a destruction physics type of game. I need to subtract all the parts that the player hits.

1 Like