Region has to be aligned to the grid error

Hello, so ive recently created a prefab placement module for smooth terrain, however i have encountered the following error in my output: Region has to be aligned to the grid (use Region3:ExpandToGrid) which points to this line.

as seen in output:

portion of code it points to:

but as seen in my code where the error is happening line 100, on line 99 i do expand the region [note:] voxelRes in this instance is defined as 4 at the start of the module and never changed. for those wandering this error persists even after exchanging voxelRes for just 4.

i have tried, task.wait() to see if it needed time to complete the method but it didn’t do anything.

Currently this doesn’t halt my script in anyway, and the remaining script runs completely fine. The only problem this is causing is clogging up the output with errors that dont seem to be errors, idk.

Anyone else run into this problem?

Heres the prefab Placement for anyone curious.

terrain before pasting:

terrain to copy/paste:

terrain after pasting and blending:

Looking at the documentation, Region3:ExpandToGrid returns the updated region, rather than updating the region directly.

If you replace line 99 with

region = region:ExpandToGrid(voxelRes)

does it fix your issue?

1 Like

Yes this does fix the issue, i didn’t realise this was the case, ive always used the way i have when scripting terrain and its always been fine. Thanks!