Hi. I have a folder inside a player (not the character) and I want to save it in a datastore. However, it doesn't seem to work. I'm highly confused, any help?
local DS = game:GetService("DataStoreService"):GetDataStore("Items")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local folder = Instance.new("Folder")
folder.Parent = plr
folder.Name = "Folderitems"
local plrkey = "id2_"..plr.userId
local savevalue = folder:GetChildren()
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
local input = GetSaved[1]
local values = input:split("|")
for i = 1, #values do
local number = Instance.new("NumberValue")
number.Name = values[i]
number.Parent = folder
end
else
local NumbersForSaving = {savevalue}
DS:GetAsync(plrkey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local savevalue = plr.Folderitems:GetChildren()
local concat = table.concat(savevalue,"|")
DS:SetAsync("id2_"..plr.userId, {concat})
end)
Right now I'm getting this error: ServerScriptService.DataStore2:27: invalid value (userdata) at index 1 in table for 'concat'

2 comments
Are you attempting to use Datastore 2? Do you have the module script, because the error looks like a Datastore2 error.
If you are, then you won't be able to use SetAsync and the module script will handle getting the "DataStoreService."