Dance floor patterns and performance concern

Hello everyone! I am currently making a game which involves 25x25-tiles dance floor with unique patterns which can be summoned at any time on the floor. However I am very concerned with the performance while I’m doing this.

Because this is a multi-layered (multi-pattern) dance floor; on refresh function in AniCore script currently, the floor has to loop 625 tiles (25x25) times everytime a pattern is created/updated; each tiles looped has to track for tile corresponding to the latest pattern summoned on that frame

Video demonstration

This is my example with 16x16, because it is a 256-tiles loop only, it shouldn’t matter much

In this example, there are 2 patterns layered on each other, pattern 1 (checkerboard) stays constant while pattern 2 (white line) keeps summoning over and over and has to override the 1st.

The way how my mechanic currently works consists of tileArr with size of 256 (16x16 tiles), each element is another array consisting group of {id, color}; and an AniTemplateCore script to execute sequence of layers (aka summoning layer scripts). If the frame of one pattern is iterating, it will trigger the AniCore script to keep refreshing. Each tile looped in refresh will check for the last group in array inside tileArr[num] and apply that color. For example, tileArr[4] = {{1, 2}, {2, 6}, {3, 5}}; the refresh will check for last element, which is group {3, 5} and apply color 5 to tile 4

So my question here is, is there a suggestion to apply multi-thread for this refresh function to avoid choppy 625 tiles looping in a very short time and avoid server lagging? Either I could try generate multiple coroutines for each tile group (5x5 each), or 1 script per tile, or something else?

I’m not entirely sure what your code looks like, but most likely your bottleneck is going to be server-to-client network replication. When a lot of changes occur all at once on the server, the server kind of streams in those changes to the clients. Thus I would probably recommend trying to make this system client-side with a LocalScript and then benchmark performance after that.

I don’t know if myself or anyone would be able to give a fair recommendation otherwise without any code shown.

pre-generate all the tile colors, then reposition them every time, if it won’t work for you (which it should work), then I don’t know.

if you don’t want any choppy, then give the task to the client who will handle it instead.