Recently I have been trying to learn and understand ProfileService, and I was wondering if someone could explain or leave a link on how to save parts and their positions, like in a building game,
Heres the basic template of ProfileService that I got of youtube that im using
they use a method called “serializing” for saving and “deserializing” for loading; they are actually quite simple where you just convert an Instance into a save-able table, e.g:
local function serializePart(part: BasePart)
local pos = part.Position
return { -- store the important properties
name = part.Name; -- store the name
brickcolor = tostring(part.BrickColor); -- store the color as a string (since you can only store string, boolean, numbers, etc)
position = {x = pos.X, y = pos.Y, z = pos.Z}; -- store the position as a table
}
end
print(serializePart(workspace.Baseplate)) -- { name = "Baseplate", color = "...", position = "..."}
(encode the serialized data to a json string for saving)
its pretty much the same for deserializing
local function deserializePart(data)
local part = Instance.new("Part") -- create the part
part.Name = data.name -- set the part name
part.Color = BrickColor.new(data.brickcolor) -- construct the color from the string
part.Position = Vector3.new(data.position.x, data.position.y, data.position.z) -- construct the position
part.Parent = workspace
end
deserializePart(serializePart(workspace.Baseplate))
keep in mind these function are untested and therefore could be a mistake or possibly an error;