Why won't this script save my building? (datastore)
local player = game.Players.LocalPlayer
local save = {}
local datastore = game:GetService("DataStoreService")
local store = datastore:GetDataStore("Buildings")
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
if v.Name == "Save" then
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("BasePart") then
local partandCFrame = v.."!"..v.CFrame --ERROR HERE
table.insert(save, partandCFrame)
end
end
store:SetAsync(player.UserId, save)
else
if store:GetAsync(player.UserId) then
for i, v in pairs(store:GetAsync(player.UserId)) do
if v:IsA("BasePart") then
local newpart = Instance.new("Part", workspace)
newpart.Anchored = true
for i, v in pairs(string.split(v, "!")) do
if tonumber(v) then
newpart.CFrame = v
end
end
end
end
else
warn("NO SAVED DATA")
end
end
end)
end
end