How do i save and load objects in a model?

In a future, i want to make a game where you can build your own house, but the problem is i dont know how to save childrens from the model/folder which contains furnitures, and load them later. I tried to search some threads, but they were not useful for me. Thanks for reading, and i hope you help me :+1:

Also, i don’t know if a hacker can clone a furniture and put it in the model, it’s possible? if that’s so, then how i can avoid that?

You would have to use data stores and store in the positions or you can use SavePlaceAsync if it’s an individual place.

Please search the dev forum before putting out topics, the answer is provided in this article:

1 Like

@someonedie - Yeah, but how can i do that?


@Hello42bacon - I already said it, i don’t know if i have explained correctly:

have you looked through the thread I provided? I have put a video in there that explains how to save models.

1 Like

I have never done this before, so this is probably not the most efficient method

Make a function that can encode and decode BasePart properties from tables, for example
CFrame.new(43, 1, 45){CFrame = {43, 1, 45}}

You would only want to encode properties relevant enough to save, you should ignore encoding something like RotVelocity (unless you use it in your houses)

In the end, you should be able to turn a part into a table like this:
{CFrame = {5, -2, 4}, CastShadow = true, Material = "Neon", Orientation = {0, 40, 21}, Parent = "Couch"} (missing some properties but you get the idea)

Then its just a matter of saving those part tables to a datastore and loading them when needed

If you plan on your building game being voxel/stamper based (see games like Sandbox and Welcome to Roblox Building) what those games probably do is assign unique IDs to all of the available models, so that saving and loading only requires you to know the id, position, and rotation of each element, rather than having to keep track of every property of every basepart.

2 Likes