I’m currently trying to make a save system for the entire workspace to save in datastore, except for the terrain. I wrote some crappy sript. But it doesn’t work. Can you suggest how to do it. Or what should I add?
Right now its looking like: Test - YouTube
Code:
local datastore = game:GetService('DataStoreService'):GetDataStore("MapSave")
local FolderToSave = game:GetService("Workspace")
local InfoToSave = {}
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message:lower() == "/save" or Message:lower() == "/save " then
for i,v in pairs(FolderToSave:GetChildren()) do
if v.ClassName == "Model" then
v = v:GetChildren() print("Model")
elseif v.ClassName == "Camera" then
print("camera found")
elseif v.ClassName == "Terrain" then
print("terrain found")
elseif v.ClassName == "Folder" then
print("folder found")
else
local PartInfo = {
["Name"] = v.Name;
["Size"] = v.Size;
["Position"] = v.Position;
}
table.insert(InfoToSave, PartInfo)
end
end
end
local good, info = pcall(function()
return datastore:GetAsync(Player.UserId)
end)
if Message:lower() == "/load" or Message:lower() == "/load " then
if good then
for i,v in pairs(info) do
local NewPart = Instance.new("Part", FolderToSave)
NewPart.Name = v.Name
NewPart.Size = v.Size
NewPart.Position = v.Position
end
end
end
datastore:SetAsync(Player.UserId, InfoToSave)
print("Saved!")
end)
end)