Parts when i save them:
the green thing is the plot
Parts when i move the plot and load it:
they are out of the plot
i want the parts to move to the plot location
here is my script:
local datastore = game:GetService("DataStoreService")
local PltData = datastore:GetDataStore("PltData")
local plrs = nil
local savingtable = {}
function onPlayerEntered(player)
player.Chatted:connect(function(msg)
if msg == "!get" then
if player.Plot.Value == false then
print("GOT PLOT")
local plotpart = game.ReplicatedStorage.Plots.Part:Clone()
plotpart.Parent = workspace.Plots
plotpart.Name = player.Name
plotpart.Position = player.Character.Torso.Position
local folder = Instance.new("Folder")
folder.Parent = plotpart
folder.Name = "content"
plotpart.Position = Vector3.new(plotpart.Position.X,159,plotpart.Position.Z)
player.Plot.Value = true
end
end
end)
end
function Loading(player)
local plr
plr = player
local data
local succes,errormsg = pcall(function()
data = PltData:GetAsync(plr.UserId)
end)
player.Chatted:connect(function(msg)
if msg == "!load" and player.Plot.Value == true then
local succes,errormsg = pcall(function()
data = PltData:GetAsync(plr.UserId)
end)
if succes and data ~= nil then
for i,v in pairs(data) do
local inst = data[i]
local part = Instance.new("Part")
part.Parent = game.Workspace.Plots:WaitForChild(plr.Name).content
part.Anchored = true
part.Position = Vector3.new(inst["PosX"],inst["PosY"],inst["PosZ"])
part.Rotation = Vector3.new(inst["RotX"],inst["RotY"],inst["RotZ"])
part.Size = Vector3.new(inst["SizeX"],inst["SizeY"],inst["SizeZ"])
part.Color = Color3.fromRGB(inst["ColorR"]*225,inst["ColorG"]*255,inst["ColorB"]*255)
part.Material = inst["Material"]
part.CanCollide = inst["CanCollide"]
part.Transparency = inst["Transparency"]
part.Reflectance = inst["Reflectance"]
end
end
print("DONE DONE DONE DONE DONE DONE DONE DONE DONE LOADING")
end
end)
end
game.Players.PlayerAdded:connect(Loading)
game.Players.PlayerAdded:connect(onPlayerEntered)
function Saving(player)
player.Chatted:connect(function(msg)
if msg == "!save" and player.Plot.Value == true then
table.clear(savingtable)
for i,v in pairs(game.Workspace.Plots:WaitForChild(player.Name).content:GetChildren()) do
local newtable = {PosX = v.Position.X,PosY = v.Position.Y,PosZ = v.Position.Z,SizeX = v.Size.X,SizeY = v.Size.Y,SizeZ = v.Size.Z,ColorR = v.Color.R,ColorG = v.Color.G,ColorB = v.Color.B,Material = v.Material.Name,CanCollide = v.CanCollide,Transparency = v.Transparency,Reflectance = v.Reflectance,RotX = v.Rotation.X,RotY = v.Rotation.Y,RotZ = v.Rotation.Z}
table.insert(savingtable,newtable)
end
PltData:SetAsync(player.UserId,savingtable)
print("DONE DONE DONE DONE DONE DONE DONE DONE DONE SAVING",savingtable)
end
end)
end
game.Players.PlayerAdded:connect(Saving)