Many Roblox games have housing in which you can decorate and expand your own house. I have questions on how to develop such systems. Thanks for any guidance!
1. Neighborhoods
Neighborhoods consist of an area that can hold a limited number of player houses. The houses can look different depending on the type of house the player is building.
Q: How do you save a neighborhood?
I can’t imagine this is done with a DataStore.
Q: How do you distribute players into neighborhoods?
Do you just assign the player to a random neighborhood that has an opening?
Q: How do you create additional neighborhoods?
With so many players, neighborhoods fill up, and thus many additional neighborhoods are needed.
2. Houses
Houses can be different for each player, and each house contains the player’s decorations and furniture, etc.
Q: How do you save a house?
In a game like Meep City, I assume this is done with the Create/Save Place API, since it appears that players teleport whenever they enter a house.
But in a game like Welcome To Bloxberg, there is no teleportation, and so I am not sure how they go about saving each home with all of its contents.
The ‘teleportation’ in MeepCity is not a place teleport. The C/S Place API is not designed for such purposes either.
Storing a house in a DataStore ain’t as hard as it may seem. No instances are being saved or anything, that wouldn’t work either. Instead, you’ll have to think of ways to convert your house objects into data which can be saved on a DataStore, and vice versa.
Simple example
houseDataExample = {
BlueprintType = 1, -- Say you have different blueprints, you can e.g. assign a unique number to each
RoomData = { -- For storing data for your specific blueprint. Make sure to reset this when switching blueprints
Room1 = {
Floor = "Pebble", -- Something to identify your floor
Wallpapers = {
Left = "BlueBubble", -- Something to identify your wallpaper
Right = "RedBubble", -- etc
}, -- etc
}, -- etc
},
Furniture = { -- This should be an expandable list rather than a dictionary
{
Type = "Sink", -- Identifier for your furniture item
RootPartCFrame = <CFrame> -- CFrame for your root
-- This is pretty much all you need! Can of course be expanded by color, etc
},
{
Type = "Toilet", -- Must-have in my example
RootPartCFrame = <CFrame>
}, -- etc
}
}
Make sure to save RootPartCFrames relative to some part of the blueprint. Preferrably each blueprint also has some sort of RootPart, which can be used to move the entire house to the plot selected for a certain player.
To answer your other questions, there are various ways to tackle these problems with a working system. Choose whatever you think your players will like the most.
EDIT:
Ideally your ‘editing’ script edits both the save data and the house’s objects simultaneously. You should avoid placing objects first and later reading values such as CFrame to create a save data table. Furthermore, you should have a way for the server to identify an object by its representive save data table entry and vice versa. Can for example be done by simply temporarily saving the furniture object as a value to the table.
Meep City doesn’t use C/S Place API. I am sure Meep City serializes data so it can be stored inside the datastore and then the data gets deserialized and loaded. I also think that they do not insert new instances into the players’ houses as if they did, the datastore would get flooded and there wouldn’t be much space for other data to be saved. It is also an inefficient method as there are better alternatives. I assume that meep city puts their models in server storage or somewhere else and according to the instructions of the deserialized data they load the models in the players’ houses. By the way I have made a game where you can build things and the things you build get saved when you rejoin. It is not that good tbh but it works, you can get a reference from my code to see how data serialization and deserialization works. There are some bugs, if there are more than 2 servers running data will get overrided and not only that but I am not using multiple keys for the datastore so that means that there is a limit, if it is/got reached data won’t save. The way I serialize and save the data isn’t that good either, it takes 196 characters space to save 1 part (more or less depending on the properties). This is just a reference of data serialization and deserialization. It is not really the correct way to go. Considering your game has models and not parts to be serialized you would need to give instructions to the script to clone models from your model storage and change their properties according to the data saved. So yeah, that is pretty much it. Here is the game. It is uncopylocked
In the game I’m making right now I need to save levels that the user have created. I do this by creating an object called CustomLevel. This custom level object contains information about the custom level as a whole, like the theme used and the name. But It does also keep a table with block objects. These blocks are essentially what the player places on their custom level. They could be spikes, jump pads etc. So the block objects keep track of blocktype, relative position etc.
Then I can load the entire level based on the data that I kept track of.
I strongly recomend that you use object oriented programming like my example above ^^^