Advertisement
DragonYTPastesWork

Save Script

Aug 11th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. game.ReplicatedStorage.SaveBuild.OnServerEvent:Connect(function(player)
  2.     local partTable = {}
  3.    
  4.     for i, inst in pairs(workspace:GetChildren()) do
  5.         if inst.Name == "BuiltBlock" then
  6.             local position = {
  7.                 X = inst.Position.X,
  8.                 Y = inst.Position.Y,
  9.                 Z = inst.Position.Z
  10.                
  11.             }
  12.             local material = inst.Material
  13.             local color = inst.BrickColor
  14.             local size = inst.Size
  15.             partTable[i] = {Position = position, Material = tostring(material), Color = tostring(color), Size = tostring(size)}
  16.         end
  17.     end
  18.    
  19.     local success, err = pcall(function()
  20.         BuildsDataStore:SetAsync(player.UserId, partTable)
  21.     end)
  22.    
  23.     if success then
  24.         print("Saved player build.")
  25.     elseif not success and err then
  26.         print("Not successful: "..err)
  27.     end
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement