Hello, I’m wondering how I can reduce lag? Basically, my placement system uses mouse.Target, therefore I have to make the whole map out of 3x3 blocks. Would this cause lag or no, and is this the best way to go about this?
Thank you,
SilentSuprion
Hello, I’m wondering how I can reduce lag? Basically, my placement system uses mouse.Target, therefore I have to make the whole map out of 3x3 blocks. Would this cause lag or no, and is this the best way to go about this?
Thank you,
SilentSuprion
If your entire map is made up of 3x3x3 blocks, it’ll get very laggy very fast. For example, let’s say you have a map which is relatively small, coming in at 300 x 300 x 300 studs. A simple cube if you must. If there is a cube in every single block of this, there will be about 1 million I think? My maths isn’t the closest. Either way, it’s a big number, and there are way more efficient ways to do it.
For example, instead of getting the brick that the mouse is on, you could have an imaginary grid, find the players mouse position and then divide and clamp it into the grid.
So, something like
x = math.floor(mousePos.X/3) * 3
Right?
Sorry for the late response, but yeah that would work. You would have to do that for all 3 which I presume you already know but then you can simply reconstruct its x y z into a new part and your placement system should work.
Okay, I managed to make it work, but the offset is kind of weird from my mouse since it’s grid of 3 any idea to fix this and if it you hit the center it just goes back and fourth.
Okay, I ended up making it work. Thank you! What I did what instead of math.floor I used math.round which in my case worked.