Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cannot store array, data store only stores valid UTF-9 characters?

Asked by 4 years ago

I tried to make a saving system by saving the parts info. It works without the datasave testing, but when adding datasave, it says: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters. script:

local datasave = game:GetService("DataStoreService")
local save = datasave:GetDataStore("Save1")
game.Workspace.RemoteEvent.OnServerEvent:Connect(function(plr,model)
    local props = {}

    for i,v in pairs(model:GetDescendants()) do
    if v:IsA("BasePart") then
    table.insert(
        props,
        {
            ["Color"] = v.BrickColor.Name;
            ["Rotation"] = v.Rotation;
            ["Anchored"] = v.Anchored;
            ["Position"] = v.Position;
            }
    )
    v:Destroy()
    end 
end
wait(1)
save:SetAsync(plr.UserId,props)
end)
game.Workspace.RemoteEvent2.OnServerEvent:Connect(function(plr)
    local e = save:GetAsync(plr.UserId)
    for i,v in pairs(e) do
        local e = Instance.new("Part")
    e.Parent = game.Workspace.Model
    e.Position = v.Position
    e.BrickColor = BrickColor.new(v.Color)
    e.Rotation = v.Rotation
    e.Anchored = v.Anchored
end
end)

Answer this question