Terrain:ReadVoxels :WriteVoxels :ReplaceMaterial Suddenly error from not being aligned to grid 4/30/2025

I googled this error I have started recieving today from ReadVoxels and WriteVoxels usage in my code and found this Bug Report from last year reporting it and it being fixed. But now it has reappeared. and is breaking everything

This is breaking anything that uses ReadVoxels/WriteVoxels without expanding to a grid.

workspace.Terrain:ReadVoxels(Region3.new(-2,-2,-2),Region3.new(2,2,2), 4)   

In all my years of development in ROBLOX I have not seen an update like this. Is this a bug?
I have gone through my code and updated it with :Expand to grid where necessary but I’m not sure what kind of behavioral or performance drawbacks this has.

After updating my code the ReadVoxels just seems broken to me now

I had this set to Region:ExpandToGrid(4) But it still says Region has to be aligned to the grid.

Expected behavior

Typically :ReadVoxels and :WriteVoxels does not break the code when using any valid region.

Edit: This bug also applies to ReplaceMaterials

This breaks many published things and I will have to update my public resources to fix this issue.

1 Like

Hi @Magus_ArtStudios, can you please elaborate in which ways is this breaking things? It is supposed to be only a warning message, nothing should be changed in the actual code behavior, and it’s only enabled for Studio for now, while we wait for everyone to fix the problems. If that is not the case, please let us know where so we can fix this. Thanks!
Please be advised that the line you posted, the one which reads from -2 to +2… that’s not aligned to 4. Because 2 % 4 is not 0. Using such ranges means that the code internally snaps it to the closest values that are aligned, but unfortunately this is an old oversight, and the rounding mode is inconsistent and imprecise.
We recommend using ExpandToGrid as we cannot guarantee that the current ā€œaccidentalā€ rounding will stay for long. It is not officially supported as you can see in the docs. ExpandToGrid is just a simple rounding calculation and jf you are calling any voxel r/w functions, this should be a negligible overhead.

I have fixed all the issues with my code concerning this, but it caused a ā€˜stack end’ not just a warning. Before the update, I could input a small region such as -2 ,+2 which equals one voxel the region has x of 4 y of 4 and z 4, Which I thought was correct but I have changed it to a 3 size and it doesn’t throw the warning anymore.


image

I have also read the documentation on these methods and have noticed that it now says Must be snapped to the voxel grid. The issue is workspace.Terrain:FillBlock, :FillCylinder, :FillBall, :FillWedge etc ALL internally snap to the voxel grid so this new behavior is actually somewhat inconsistent with the other Terrain methods. It also breaks a lot of the resources and games that use :ReplaceMaterial, :ReadVoxels, and :WriteVoxels.

In conclusion, this causes a stack end warning that stops the behavior of the code beyond that point. It’s inconsistent with the :FillBlock, :FillWedge, :FillBall,:FillCylinder methods that snap to the grid automatically. I would rather the behavior remained the same becuase now I have some public resources that I have created that I have to update. Then, there are the public resources that won’t be updated by the OP and left in a broken state. Additionally, this situation is almost the same as a bug report last year that was fixed concerning all terrain methods requiring :ExpandToGrid all of a sudden.