Is it posible to datastore builds?

i am currently making a game where you build, explore and other things but i want it to save the builds of a player, it is very hard to me to understand datastore and i cant find anything usefull in the dev wiki, please help :pleading_face:

1 Like

Datastores save tables of data. They cannot store instances so to do so you need to store sufficient data about the instance to reconstruct it when you load the data store.

Yes, it is possible. A lot of building-based games already do it.

One of the major issues to address is data size. Compression and serialisation strategies are worth investing time into, since build-based games with saves are known to be very data-heavy. Presets are also good; rather than saving everything piece-by-piece, save an entire assembly as an id and just keep its position and rotation, plus additional configurations.

The Developer Hub mostly contains practical examples and documentation. Most implementations of each item are dependent on you. None of the concepts I listed is available there, so it’s worth asking questions about those or doing some research.

alright thanks!, it should be saved in a table right?

Yeah it has to be saved in a table. For example, if your game depends on building objects that are already built by you and saved in the game as models, then you can store the position and rotation of the model where the player has built it during the gameplay.
So to reduce data cost I would assign IDs to the models and the data of the player would look like that for example:

local player1Data = {
    buildings = {
        {ID = 1, Position = positionOfTheModel, Rotation = rotationOfTheModel},
        {ID = 1, Position = positionOfTheModel, Rotation = rotationOfTheModel},
        {ID = 2, Position = positionOfTheModel, Rotation = rotationOfTheModel}
    }
}

I want to point out that here I ‘saved’ two models of ID 1 and one model of ID 2.
Then when the player joins the game, the models will be simple cloned and placed in the right position and rotation.

1 Like

the ID is like somehow for example the type of building?

It depends whether you have prebuilt models that can be placed by the player or they just build something random using parts.

1 Like

See:

This is about what an id system comes down to. It’s related to what I said earlier:

1 Like

i will include a data limit of course, since there are like 20 layers of places where you can place blocks, 4 that cannot be used, so the block limit should be 16*176

then explain how the other people explained how to save the thingies

You can have a module that stores information about models and their IDs, e.g.

local models = {
    [1] = game.ServerStorage.Models.Wall;
    [2] = game.ServerStorage.Models.Door;
}

return models;

ah so thats like a sorting system i can make so i or the server doesnt need to write the names of the objects

Yeah that’s the point to reduce the cost of data, instead of saving the names you just save the IDs :relaxed:

1 Like

aight thanks a lot :heart:
i will try to make the script right now and update if it works

1 Like

do you have discord? if you do, if you would add me and help me a bit i will apreciate it!

Yeah, I will send a private message to you on DevForum.

Others save it by, as I said, storing enough data to reconstruct the constructions from said data without loss.

For example, let’s say you have a block. You probably want to store the type of block, anything in it (if it has an inventory), position, and orientation if applicable. The rest can be filled in from defaults; you don’t need (nor can you) store the entire model.