Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to save structures in datastore?

Asked by 3 years ago

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

1 answer

Log in to vote
0
Answered by 3 years ago

Similar Question

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.

0
But how would you save a huge amount of objects? Zeta_Dev 34 — 3y
0
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 SpectacularPavlos 86 — 3y
0
So would I have to define multiple of the same object? Zeta_Dev 34 — 3y
0
What if I had 2 of them, would they both spawn or would just 1 spawn? Zeta_Dev 34 — 3y
0
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) SpectacularPavlos 86 — 3y
Ad

Answer this question