I have a script doing things will datastore and I get this error message on line 23. I'm not sure what it means.
20:07:36.433 - Argument 2 missing or nil
20:07:36.433 - Stack Begin
20:07:36.434 - Script 'ServerScriptService.Saving', Line 23
20:07:36.434 - Stack End
Here is my script. What am I doing wrong and how do I fix it?
local DataStore = game:GetService("DataStoreService"):GetDataStore("Banned")
game.Players.PlayerAdded:connect(function(player)
local Folder = Instance.new("Folder")
Folder.Name = "Players"
local UserN = Instance.new("BoolValue")
UserN.Name = player.Name
UserN.Value = false
Folder.Parent = game.ServerStorage
UserN.Parent = game.ServerStorage.Players
local key = "player-"..player.userId
local savedStats = DataStore:GetAsync(key)
if savedStats then
--Save Format: {HasHome,Something}
UserN.Value = savedStats[1]
else
local Saving = {UserN.Value}
DataStore:SetAsync{key, Saving}
end
end)

2 comments
SetAsync thinks you're saving a table as the key and nothing as the value. You should be using parenthesis, not brackets.
Thanks. That working.