I am not too experienced with data stores, and i am having trouble saving my player's string value data. And yes, i tried the wiki and stuff but it still doesnt seem to work.
This is what i tried so far:
local ds = game:GetService("DataStoreService"):GetDataStore("Stats")
local stats={"Slot1","Slot2","Slot3","Slot4","Slot5","Slot6","Slot7","Slot8","Slot9","Slot10"}
game.Players.PlayerAdded:connect(function(plyr)
local a=Instance.new("StringValue")
a.Parent=plyr
a.Name="Characters"
for i=1,#stats do
local stat=Instance.new("StringValue")
stat.Parent=a
stat.Value = "None"
stat.Name=stats[i]
end
local child=plyr.Characters:GetChildren()
for i=1, #child do
child[i].Value=ds:GetAsync(plyr.userId..child[i].Name)
end
end)
game.Players.PlayerRemoving:connect(function(plyr)
local child=plyr.Characters:GetChildren()
for i=1, #child do
child[i].Value=ds:SetAsync(plyr.userId..child[i].Name,child[i].Value)
end
end)
I get this from Output:
18:19:12.490 - ServerScriptService.DataStore:16: bad argument #3 to 'Value' (string expected, got nil)
18:19:12.491 - Stack Begin
18:19:12.491 - Script 'ServerScriptService.DataStore', Line 16
18:19:12.492 - Stack End
If someone can help then i would be greatly appreciated. Thanks!

5 comments
I tried this out, but it is for some reason still giving me the same error in output, but now in line 20 (v.Value = value). I cant seem to find whats wrong with this :(
Try printing v.Value and value variable and look at the results.
v.Value prints as "None", and value prints as "Nil", so that may be the problem
I think the problem is that when a player joins for a first time, the corresponding data store for that player is nil. This is why the value variable equals nil. Let me fix this in the answer.
Okay, i fixed it Lol. It turns out i had to check if it was "nil", and then if so then do: value=ds:SetAsync(plyr.UserId..v.Name,"None"). Thanks a lot for the help!