Scripts that change a parts properties, like color, or destroy a part, cause the game to lag. I want to know more as to why this is.
I’ve noticed that whenever a serverside script changes a parts property or destroys a part, the game lags for a second. According to the performance tab, the heartbeat slows down. I experimented and found that this has something to do with the amount of parts in the project, as removing projects or enabling streaming improves performance. I tried making a part that constantly changes color in a while loop, and even if i increased the wait time every loop it still froze up for a second.
I have optimized the game by enabling streaming and making areas unload when no players are present. But I would like to know more about what causes the lag and other ways I might be able to optimize it.
I know this question is kinda vague, so feel free to ask me any questions and I will do my best to answer. Thanks.