I want the terrain out of a certain boundary to unload, and terrain in a certain boundary to load.
The code I have made does not unload the terrain properly, where the farther the player gets from the world origin, the closer the unloaded terrain boundary gets, until the player falls into the void. But the main issue is that I do not know what problematic code is.
I have commented almost everything just in case I could catch anything, but this did not work.
Here is the rbxl file so you can test it yourself:
Newest Version: TerrainGen.rbxl (66.3 KB)
Update:
Tested values for “chunk_x” in the for loop around line 199 (may differ since I have been making changes) and got this:
Since render distance is currently set to 10, this should not be printing. It should go from -500 to 500 in 100 stud increments (which would print 10 things before repeating), but it does not.
Below is an image of what the terrain looks like during this bug.