Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Argument 2 missing or nil? How do I fix this?

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

1

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

0

Thanks. That working.

1 answer

SetAsync thinks you're saving a table as the key and nothing as the value. You should be using parenthesis, not brackets. -M39a9am3R

This discussion is preserved as it was. New answers, comments, and votes are closed.