hey, im trying to make a datastore system for my storage. but there is a little problem. i keep getting this error “104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.”
im not rlly good at datastores, so i have no clue what it means. i tried fixing it but… didnt work. (this script isnt mine, i just modified it)
game.Players.PlayerAdded:Connect(function(player)
local storage = player:WaitForChild("Storage")
local load = ds:GetAsync("User_"..player.UserId) or {}
if type(load) == "table" then
for i, v in pairs(load) do
for name, value in pairs(v) do
local object = Instance.new("ObjectValue")
object.Parent = storage
object.Name = name
object.Value = value
end
end
else
load = {}
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data = {}
local storage = player:WaitForChild("Storage")
for i, v in pairs(storage:GetChildren()) do
if v:IsA("ObjectValue") then
local nameAndVal = {}
nameAndVal[v.Name] = v.Value
table.insert(data, nameAndVal)
end
end
local res = ds:SetAsync("User_"..player.UserId, data)
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
local data = {}
local storage = player:WaitForChild("Storage")
for i, v in pairs(storage:GetChildren()) do
if v:IsA("ObjectValue") then
local nameAndVal = {}
nameAndVal[v.Name] = v.Value
table.insert(data, nameAndVal)
end
end
local res = ds:SetAsync("User_"..player.UserId, data)
end
end)
if you have any ideas why it doesnt work please comment below.
so here, im trying to save just the items name. but it sitll gives me a error. (DataStoreService: CantStoreValue: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. API: SetAsync, Data Store: DataStoreTest - Studio
game.Players.PlayerAdded:Connect(function(player)
local storage = player:WaitForChild("Storage")
local load = ds:GetAsync("UserAuras-"..player.UserId) or {}
if type(load) == "table" then
for i, v in pairs(load) do
for name, value in pairs(v) do
local object = Instance.new("ObjectValue")
object.Parent = storage
object.Name = value
local aura
for _,v in pairs(game.ReplicatedStorage.Auras:GetChildren()) do
if v.Name == value then
aura = v
end
end
object.Value = aura
end
end
else
load = {}
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data = {}
local storage = player:WaitForChild("Storage")
for i, v in pairs(storage:GetChildren()) do
if v:IsA("ObjectValue") then
local val = v.Value.Name
table.insert(data, val)
end
end
local res = ds:SetAsync("UserAuras-"..player.UserId, data)
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
local data = {}
local storage = player:WaitForChild("Storage")
for i, v in pairs(storage:GetChildren()) do
if v:IsA("ObjectValue") then
local val = v.Value.Name
table.insert(data, val)
end
end
local res = ds:SetAsync("UserAuras-"..player.UserId, data)
end
end)