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

4 comments

0

What's the error?

0

Datastore can only store UTF-8 CHaracters, line 12

0

I believe the issue is with you trying to store CFrame, I'll test it out in studio

0

SetAsync only works in server I think.