How do multiple places in a game work, and how do I make universal changes to them all?

Hello! I am currently working on a game that requires different ‘maps’ to play on. I am using Terrain, and as I’ve discovered on here, you cannot have multiple Terrain instances swapped in/out. As such, I have to use different places. There is a lot of jargon in ServerStorage and ServerScriptService that is going to be used regardless of which map is loaded. I do not know anything about the contrast between Games and Places, and I do not know how to move players to these different Terrain maps, without ditching all of the scripts and content in ServerStorage. I should note, no information needs to get passed to the new map, I just need players to move there. I do not want to have to copy/paste everything in ServerStorage and ServerScriptService over to every single map, because any changes I make to the game wouldn’t replicate to all of the other maps. If I could just run everything on the same place and load different Terrains, I would not have any issues. How should I go about this?

Tldr;
I use Terrain. I have multiple maps. I need the same code and stored content between them all. How do I move players between them and have changes to the game replicate to all maps?

3 Likes

You would move players using TeleportService. As for replicating the scripts for each one, you’ll probably have to.

You could create all your terrains apart from each other in one game then re-positioning the player to the desired terrain map,
But doing this will maybe mean lagg in your game…

Or maybe not if you don’t use the generator which mostly generates unnecessary terrain layers…

You could look into using Packages if a large portion of the code is the same and you are only using the places for new terrains.

I have not played with them yet, but it looks viable for your use case.

If you want the state of one map to continually affect the state of another that is a whole other issue that I cannot make a recommendation on.

What specifically did you read over? It is possible to swap out terrain.

You can’t swap out the terrain instance in Workspace, no, but you change the terrain data by making use of regions. Whenever you need terrain gone, you clear it using terrain’s clear method. You can then use PasteRegion on saved TerrainRegions (use CopyRegion and store the returned TerrainRegion with your map) in order to load up terrain.

You don’t need new places just because of terrain. The tools for changing out sections of terrain are already provided to you within the engine. It’d be a good idea to look at the Developer Hub for more information so you can check out how to manipulate terrain at run time.

Related objects:

Related methods:

Code samples are also provided in the pages.

1 Like

You could swap terrain as I’ve seen other games do it. You can have all of the terrain maps in the game at once, then you will use the CopyTerrain function to copy the terrain of the maps and hold them so that they can be later used. Then you can use the Clear function, or if you want to keep some terrain instead of deleting all, you can use the ReplaceMaterial function and change the target material to Air. If you want to insert a new map, you can use the PasteRegion function, and when you want to delete it, you can use the Clear function or the ReplaceMaterial function