How do I make a building save?

So, I know that I have to use Datastores. But the only experience I have with that is saving values, (Coins, Xp…)

Example of a building:
Lets say I upgrade a House to Level 2.
If I leave and return later, I want my house to still be at level 2 and not go back to level 1.

1 Like

Is the house like bloxburg, where you can customise the house to your liking, or just a house that can’t be customised?

1 Like

Nope. You cant customize it. The only way it gets customized is by Upgrading it. (Example, upgrading a cannon from level 1 to 2 in clash of clans changes it’s appearance.)

1 Like

You can save a number, and that number represents that level, and every time someone joins the game, it loads the house level from the save (The house will be saved in server storage or something), or loads a level 1 house

1 Like

Do you have an example of this? (Not the whole code) Just some examples

1 Like

I unfortunately don’t have an example of it.

1 Like

I do not understand this. Because how my upgrade system works, the game checks if the player has enough cash to upgrade it, if it does, then the current model gets Destroy() and then it would Clone() the upgraded model from the workspace and parent it to the workspace.

1 Like

Once it upgrades, you just save the level number to a datastore, like a cash datastore.

I recommend you read this article: How to save parts, and the idea of Serialization
Also, read some articles about datastores. You could get the saved number when a player joins and use that number to give them a house of that level.

1 Like

Thanks for suggesting my article! But it seems that it isn’t necessary in this case to serialize the buildings. The houses aren’t customizable, they are pre-made. Saving their type or whatever and loading the appropriate preset is a much efficient way.

1 Like

Hmm, can you give a explanation? It would help so much!

Essentially, you would have pre-sets of these houses. You can store them in ServerStorage, have a folder with all the types of houses your game has under it, where each house has its own unique name. When the player leaves, you simply save the name of the house he owns. When he comes back, you load that name, and what you do is :Clone() the house inside of the folder inside of ServerStorage with the same name, and put it where you want it to put it.

2 Likes

It’s not that simple. In that case the player has to come back to the exact same server that the player left.

Let’s assume that every object you can upgrade doesn’t get upgraded at the same time. So you can make a dictionary holding the levels of the object the player has made and then a script goes through the values and inserts the fitting object.

^ This was your concept as well.