Hello, I'm working on a game with a rust like placement system and I wanted to know if it was possible to save structures or objects in datastore? Thanks for your time. - Zeta
Is it possible to save structures in datastore?
1 answer
In the Roblox Datastore, you can only save datatypes such as Integers, Numbers, Strings, Booleans, and Tables.
If you don't know what these are go here: http://wiki.roblox.com/index.php?title=Data_types
In order to save a model, you would likely want it's position, rotation, and what it is. All the extra attributes such as customization can also be saved, but those are the main three.
For each model in your game you should have a PrimaryPart, this is not required, but makes it much easier. Therefore if you do have a PrimaryPart, you would save the following:
local pos = tostring(Model.PrimaryPart.Position) -- Can't save the position since it is a Vector3 value
local rot = tostring(Model.PrimaryPart.Orientation) -- Same here, Vector3 value
local Type = Model.Name
You can insert all of these into a table and attach it to the player's key in the datastore.
So when you load it, you would get the type of model saved, and clone it from a storage place. You would then do setPrimaryPartCFrame and set the position and rotation.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
But how would you save a huge amount of objects?
I honestly don't know if that can be done. You could save their properties and give each a object a name and also save that. Then depending on the name of the object the appropriate one whould be spawned
So would I have to define multiple of the same object?
What if I had 2 of them, would they both spawn or would just 1 spawn?
You could define a count variable and make the value of it the amount of e.g walls (Sorry if my English is bad it's not my native language)