How could I save the position of parts when a user leaves the game?

Hi there! I am making an open world structure building game, and I would like to know how to save (a wall, for example; which is 1 part) and the CFrame of it.

I know what DataStores are, and I know how to start a function when the player leaves. I have a StringValue inside each part that I want to save that tells the system that the part and it’s CFrame should be saved.

for instance, here is an example:

player1 leaves the game.Position Saving System starts.

Part and CFrame is put into a table.

player1 joins the game.Part and CFrame are inserted back into the workspace.

Also, let me know if there is a different way to do this.

Thanks!

You can do this by saving the Part name and position in a dictionary.

local Parts = Model:GetChildren()

local SaveParts = {}

for i,v in pairs (Parts) do
     SaveParts[v] = v.CFrame
end
-- Save the SaveParts table to the players key
2 Likes

thanks a lot! One more question, how would I do this:

how would I exactly go about doing this?

I used this:

Its when you save the properties of a part then create a new part with those saved properties.

I used it in my game:

I made a slot saving system:

2 Likes

Datastore:SetAsync(Player.UserId, SaveParts)

1 Like