Alright! You’re in luck, I just made this system exactly. So save after the player places, moves, or deletes any of the blocks you save the position of every block
with this
for i,v:Model in ipairs(plot.Value.Buildings:GetChildren()) do
table.insert(plotdata,{
["Name"] = v.Name,
["X"] = plot.Value.CFrame:ToObjectSpace(v.PrimaryPart.CFrame).X,
["Y"] = plot.Value.CFrame:ToObjectSpace(v.PrimaryPart.CFrame).Y,
["Z"] = plot.Value.CFrame:ToObjectSpace(v.PrimaryPart.CFrame).Z,
["RY"] = v.PrimaryPart.Orientation.Y - plot.Value.Orientation.Y,
})
end
local datamodule = require( game.ServerScriptService.Scripts.PlayerManager.GetData)
datamodule.Save("plotdata", plotdata)
so you would get all children of the folder “Build” and then insert the Name, X, Y, Z, and rotation. I only had Y rotation for this but if you want to save all rotation axes then just duplicate and replace with X and Z.
Then I saved it to a module script that does this:
local Module = {}
local data = {}
function Module.Save(name:string,data2)
if data2 ~= false then
data[name] = data2
end
end
function Module.Get(name)
return data[name]
end
return Module
So when the player is leaving you would use the get function with the player’s name to get the positions of the plot, you have to save it to a module script because the player-manager script can’t save all the data fast enough before the player leaves.
Then when the player joins you make a script that has a function for placing the blocks or machines. To use the data that was saved you would use this:
local data = datamodule.Get("plotdata")
local placemachine = game.ServerStorage.BindableEvents.PlaceMachinery
if data then
for i,v in ipairs(data) do
local position = Vector3.new(v["X"],v["Y"],v["Z"])
placemachine:Fire(player,v["Name"],position,v["RY"])
end
end
The bindable event is the function that places the machine.
I hope this helps!!!
mark it as an answer or solution if it helps