How do I datastore Objects/Models?

What are you attempting to achieve? (Keep it simple and clear)

I am trying to datastore models so any time a player joins they can load in a model. For example, if I made a tycoon game and wanted to save the whole tycoon including the bricks and scripts.

What is the issue? (Keep it simple and clear - Include screenshots/videos/GIFs if possible)

I have tried over and over again and I can’t figure out how to do this.

What solutions have you tried so far? (Have you searched for solutions through the Roblox Wiki yet?)

I have tried modifying a regular datastore for leaderboards, but that didn’t work. Also, I have looked all over the Wiki, but nothing pops up about what I need.

(Sorry if you don’t understand what I need. Just tell me if you don’t understand. Also, sorry if this is really basic, I am not very advanced into scripting. I am more of a moderate scripter.)

1 Like

You probably dont want to store the objects themselves but the bare minium data required to rebuild the tycoon on load. Do you need to save the model of the rollercoaster they placed, or just the piece IDs and their grid locations?

Save the model of the thing they placed. Also, why do you say rollercoaster?

Rollercoaster tycoon came to mind idk

1 Like

This isn’t how you’d do it. For a tycoon, you’d save exactly what they bought, then just remake the tycoon from there when they spawn.

There’s basically always a smarter way to do whatever you want to do instead of saving the exact models.

5 Likes

DataStoring doesn’t accept objects, therefor you need to save the CFrame (Location they placed it) as well as the object they placed (A string or object ID)

Example:

PlacedObjects = {
   Player1 = {
      Chair = CFrame.New() -- Index is the name, value is the CFrame
   }
}

Example 2…

PlacedObjects = {
   Player1 = {
      Object = {
         Position = CFrame.New() -- Position in CFrame
         Name = "Test" -- Objects name
      }
   }
}
1 Like

I know it’s not what they do, but I would like to know how I would do what I said in the example. The thing I am making isn’t a tycoon, that’s just an example.

What are you making? You’re giving an XY Problem.

5 Likes

Well, I’m trying to make some experimenting with it so I can use it in the future.

1 Like

You most likely won’t ever use it in the future, that’s my point. There’s very little applicable case for saving an instance instead of relevant data.

Wait wait now I have the link for this one
http://wiki.c2.com/?YouArentGonnaNeedIt

I can use it in the future, and I will. Just because most people won’t doesn’t mean I won’t.

1 Like

Ask back then when you actually have a use case for it, because there’ll certainly be a better way.

1 Like

I think you just need to use a table to store models’ ID, position/or Grid ID and some unique things appear in the model (such as Color, Text).

1 Like

For your tycoon example, you would have each object the player can buy to be in a folder on the server.

Then to save everything, save the cell/position (assuming you are using a grid system) and the item name/ID.

To load the data, simply go through the saved data and place the Item using the position/cell saved.

You are unable to save objects, only properties of objects/values

It would be helpful for you to provide your actual scenario if your tycoon example isn’t your problem.

11 Likes