How make a terrain generator

The Main Idea

Hello I’m trying make a terrain generator with a simple script that duplicates the baseplate where the player goes over and over again.

Ill be very grateful!

Thx For reading

I’m not too sure but I think you would have to use magnitude to detect if how far they are from the baseplate. Then when they are at the end make it clone on whatever side they are on. Sorry I can’t show the code, I am on mobile rn

1 Like

When I was trying to make a minecraft-like game I used perlin noise to generate terrain with seeds, and it worked well for me:

I just didn’t finish it because it got harder to edit it as I added more details and another game I had started having more visits, so I shifted my focus into it.

  • Basically you create a chunk grid with the wanted chunk size. When the player approaches an unloaded chunk, you load it, and when the player gets too far away, unload it.
  • To load a chunk you use the perlin noise with your set seed to generate terrain with a height based on x and z coordinates.
  • To save the world, I saved the changes instead of the world, because saving everything that was loaded is impossible I guess. You also have to compress data so your datastores don’t run out of data after saving just a built house and some dug caves. For example, you can save a 2x2x1000 tunnel by using only its two corner positions and filling it with the same material, instead of saving 20000 positions. The same can be done with walls and other repeating materials.

I think you should look up the math.noise function on the roblox API to understand it better:

https://developer.roblox.com/en-us/api-reference/lua-docs/math
I remember I also used this site and this video to understand better how to make a terrain generator:
https://www.redblobgames.com/maps/terrain-from-noise/

For Cave Generation: search perlin worms. You basically use a perlin noise to define where a cave starts, and it will randomly grow into another point, making a ‘worm’ shaped cave. I didn’t use it, but I think minecraft also uses premade shapes to create cave rooms at some places.

I’m making a system that will include this similar idea. If you want a baseplate that will duplicate as the player moves around, you’ll can have a couple methods of doing this.

Method 1:
On the client, track the players position (I’d recommend this mainly if it is singleplayer). When the player is moving in a direction, send the server (via RemoteEvents) a signal of the players position. Make the server duplicate the baseplate with a offset. For example, if the baseplate is x = 200 and z = 200, make the new baseplate spawn 200 studs away from 0,0,0 so it doesn’t go into the existing baseplate or have a space between existing and new baseplates. Do the same thing for removing a baseplate when the player goes away from it except you need to use the position of the baseplate and the player and track the distance between them.

Method 2 (recommended):
Do similar things like the first method, except track the players (mainly for multiplayer) on the server and remove the baseplate only when there is no player near it. Creating the baseplate would be the same as Method 1.