Argument 1 missing or nil (Second post, because no further support was given)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make it so the script functions properly
  2. What is the issue? Include screenshots / videos if possible!
    image
    Line that keeps giving the error:
Information = HttpService:JSONDecode(Information.Data)

The DatastoreUpdate Function:

function _G:DatastoreUpdate(FuncInformation,Update)
	local Player = FuncInformation.Player
	local Key = Player.UserId
		local Information = ArrestDatastore:GetAsync(Key)
		local Sentence = 0
		local Threshold = 15
		if Information == nil then
			Information = {
				Sentence = 0
			}
		ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
		end
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Uhhh, I added in Information.Data so it gets rid of the String error that kept giving me an error.
1 Like

Where in this code are you JSONDecoding? Could you please provide your entire code?

1 Like
function _G:DatastoreUpdate(FuncInformation,Update)
	local Player = FuncInformation.Player
	local Key = Player.UserId
		local Information = ArrestDatastore:GetAsync(Key)
		local Sentence = 0
		local Threshold = 15
		local Information = nil
		if Information == nil then
			Information = {
				Sentence = 0
			}
		ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
		end
			Information = HttpService:JSONDecode(Information.Data)
			if Information.Sentence ~= 0 or FuncInformation.Sentence then
				if FuncInformation.Sentence ~= nil then
					Information.Sentence = Information.Sentence + FuncInformation.Sentence
					ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
				end
Information = HttpService:JSONDecode(Information.Data)

That table is already decoded so it seems like you don’t even need that line, just remove it and see what happens.

If I remove it, it just messes the script up, I’ve tried already.

Edit: Nvm, it didn’t mess it up, however, I’ll try the test in a public server.

Okay, I believe I see the problem. Try this:

function _G:DatastoreUpdate(FuncInformation,Update)
	local Player = FuncInformation.Player
	local Key = Player.UserId
		local Information = ArrestDatastore:GetAsync(Key)
		local Sentence = 0
		local Threshold = 15
		local Information = nil
		if Information then
			Information = HttpService:JSONDecode(Information)
		else
			Information = {
				Sentence = 0
			}
		ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
		end
			if Information.Sentence ~= 0 or FuncInformation.Sentence then
				if FuncInformation.Sentence ~= nil then
					Information.Sentence = Information.Sentence + FuncInformation.Sentence
					ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
				end

This is because you were JsonDecoding no matter if it was decoded or not, if you move it into the if statement it will only decode if it’s coming directly from the datastore.

Oops, I made a tiny mistake. Try now.

What’s the mistake, because I don’t think you fixed it.

In the if statement I was doing

Information = HttpService:JSONDecode(Information.Data)

Information is a string so .Data definitely won’t work, but it doesn’t resemble the error you got.

What line is this error on?

Line 48:

If I don’t add in the .Data to the Information, then it’ll give me my String error back.

Which of those lines is line 48

Information = HttpService:JSONDecode(Information.Data)

		ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
		end
			Information = HttpService:JSONDecode(Information.Data)

Original Script:

function _G:DatastoreUpdate(FuncInformation,Update)
	local Player = FuncInformation.Player
	local Key = Player.UserId
		local Information = ArrestDatastore:GetAsync(Key)
		local Sentence = 0
		local Threshold = 15
		local Information = nil
		if Information == nil then
			Information = {
				Sentence = 0
			}
		ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
		end
			Information = HttpService:JSONDecode(Information.Data)
			if Information.Sentence ~= 0 or FuncInformation.Sentence then
				if FuncInformation.Sentence ~= nil then
					Information.Sentence = Information.Sentence + FuncInformation.Sentence
					ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
				end

That screenshot looks like you didn’t copy over the code how I had it. Try copying over exactly what I had above.

game.Players.PlayerAdded:Connect(function(Player) -- line 92
	local PushTable = { -- line 93
	Player = Player -- line 94
	} -- line 95
	_G:DatastoreUpdate(PushTable) -- line 96
end) -- line 97

It’s because I took the wrong screenshot.

The code sample you provided doesn’t look like it either.

game.Players.PlayerAdded:Connect(function(Player) -- line 92
	local PushTable = { -- line 93
	Player = Player -- line 94
	} -- line 95
	_G:DatastoreUpdate(PushTable) -- line 96
end) -- line 97

I don’t know at this point…