I wouldn't recommend using the players userId as a way to store data. Since it seems that you are only saving a table, it would be better to create a Datastore for everyone and save in accordance there.
Also, if that is the full script, you never declared what 'plr' is. You're most likely saving it incorrectly.
The following is the way I'd recommend it:
local data = game:GetService("DataStoreService"):GetDataStore("arraySaves")
game.Players.PlayerAdded:connect(function(p)
local getdata = data:GetAsync(p.userId.."_saves")
local loaddata = {unpack(getdata)}
print(table.concat(loaddata, ", "))
end)
Of course, you'd have to change the way you are saving with the method above.
However, if you want to only see the solution to your problem, you aren't declaring plr.
game.Players.PlayerAdded:connect(function(p)
local data = game:GetService("DataStoreService"):GetDataStore(p.userId)
local getdata = data:GetAsync("saves")
local loaddata = {unpack(getdata)}
print(table.concat(loaddata, ", "))
end)
3 comments
Ok thanks, and sorry I forgot to put that this is inside a Player Added function, thanks for teaching me that there is a way to unpack a table!
no prob anytime :D
Can you put this as solved please. :)