Most efficient way of saving an entire place

Im experimenting with place saving and I got it to work with saving the itemname in a table, finding the asset in the explorer, then cloning it and CFraming the item, Is there a more efficient way of doing this with a large map? Including item properties is desired. If so please explain in decent detail. :slight_smile:

I don’t know what you are saying. But, if you were referring to saying that you are making your OWN maps, then you make the map and put it into replicatedstorage and then clone it and set the parent to workspace when you need it.

Im trying to save a map that I have no control over, I know nothing about the place it’ll all be generated by the player. I need to save it after each visit.

Only save what you must. Usually in sandbox games there are certain base building blocks like a floor or fence. At that point all you have to save is the position and rotation of the primary part. Sometimes you also have to save the owner of it or something else that affects gameplay. If you do need to save the player then instead of adding the player’s id to the specific block, add the block into an array of the player. If you save color it may be a good idea to only have a couple of preset colors and group them that way too. If there are huge amounts of items this will greatly help save space. Another thing you could do is use ids attached to a name. Saving an id like 25 instead of a whole string like “A Huge Tree” will decrease the character amount a lot as well. Just think of all the ways you can group things and try to implement them. The character limit on datastores is fairly large so if you do it right you can generally keep it under, but make sure there is a max item limit of some sort.

Note: If you’re saving massive worlds it may be better to use an external service for your database. Sometimes you just can’t fit everything into Roblox’s datastores.

If you’re worried about saving every single part’s position and orientation, you can use a combination of AssetService.CreatePlaceAsync and AssetService.SavePlaceAsync. Just save it when everyone leaves.

1 Like

It is placed into the inventory of the place’s creator with the given name and description. This method will also return the placeId of the new place, which can be used with TeleportService.

If i had per say 200 different servers would 200 places be added into my inventory, if so, I plan to wipe servers, is there a method to this?

Use a datastore and save all the data in one string for the best use of available storage. Or use an external data service.

Don’t use names. Give each item an identifier, using numbers, lowercase letters and uppercase letters (base 61), so your first item is 0, your 11th item is a, your 36th item is A, and your 63rd item will be 01.

This means the minimum number of characters possible.

If you have multiple of the same item, include it’s identifier once, and list the positions afterwards. If your map snaps to a grid, then include cell coordinates instead of actual position, e.g. a 2D 120x120 grid, snapping to 3 studs, will have coordinates 0 to 39 in each direction.

So a quick example. For 5 clones of item a7, placed in cell coordinates (1, 6); (3, 4); (20, 7); (2, 35); (0, 0), and one clone of 6B in (7, 3) you could have:

a7:1,6;3,4;20,7;2,35;0,0/6B:7,3/

You could add rotation snapped to a certain degrees as a third coordinate. E.g. snapping to 15 degrees increments would be rotation 5 for an object rotated 75 degrees to the world axis.

a7:1,6,5;3,4,0;... for 75 and 0 degrees on those first two.

The optimisations you can make really depend on your exact setup. The more constrained your placement is, the more you can compress. If you’re dealing with large numbers for your coordinates, encode them in base 61 or base 64 like we did with the identifiers, and it’ll take up less characters.

You then use string manipulation to split up the string by the various delimiters (comma ,, semicolon ; and slash / in the examples I gave), and then progressively load in the map items.

If you allow completely free positioning in 3 dimensions, and rotate in all three axes, then you may hit the datastore character limit for a single key.

I’m doing something similar with my citybuilding game. Once you’ve got your rules in place you can grab your longest identifier, your largest coordinates, and the maximum number of objects to work out the longest possible string. If this is too long for a datastore then you’ll need an external service or you’ll have to split up the string into multiple keys, which can get messy if one fails to save.

3 Likes