Datastore "Argument 1 Missing or Nil" Warning

Second post today about the same piece of code… fun lol. Anyways, I’m making a new datastore, and the saving function I’m using isn’t working. Basically, I put in a number value (in this case, the player’s money), and it should save it to a metatable with all player’s information in it. However, when I try to save, I get the error, “Argument 1 Missing or Nil”, and the only argument I’m using (player’s money) prints out fine. Not sure what I need to do here, but any help is appreciated!

Code:

function Module:SaveData(fTokens)
	local FTokens = fTokens
	print("Module data inputted: " .. fTokens) --The value is clearly here when it is printed...
	local Suc, Response = pcall(function()  
		self.DataStore:UpdateAsync(self.UserId, function(FTokens)
			self.Data.FrenzyTokens = FTokens
			return self.Data
		end)
	end)
	if not Suc  then
		warn("Save data falure!", Response)
	end

end

First off, why are you naming your parameter the exact same as your variable both as FTokens? Second, why is the old data (FTokens) being used as a number while the new data (self.Data) is being saved as a table?

Other than that, I think your problem is because self.UserId is nil. Try checking that.

You can simply the code with the following:

local ds = self.DataStore
lcoal s,r = pcall(ds.UpdateAsync, ds, self.UserId, function()
    return self.Data
end)

I dont see why you are applying the Data during the save instead of in the background, also the argument inside the UpdateAsync function is literally your old Data, so you are basically giving the Player their old Data instead of actually updating it with their current Data.