What exactly is the 2nd argument of :UpdateAsync()

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!

I am trying to save properties of a (players) part to a datastore

  1. What is the issue? Include screenshots / videos if possible!
    I don’t understand the 2nd argument of updateasync()

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried discord servers and searching the web but i still do not understand it

My code:

func.OnServerEvent:Connect(function(plr, properties)
	local userID = plr.UserId
	local key = "Player_"..userID
	local success, ret = pcall(datastore.UpdateAsync, datastore, key)
	if properties then
	if success then
		properties = ret
			local success, ret =  pcall(datastore.UpdateAsync, datastore, key)
			print("Error saving data (Please retry?)".. ret)
		success == true or not Players:FindFirstChild(plr.UserId)

2nd argument of :UpdateAsync() is callback function.

Here’s an example:

DataStore:UpdateAsync(key, function()
	return Points.Value
1 Like

So is it just a function that passess into the next?

I didn’t quite understand this question.

Basically, you get to write a function that reads the current saved data and you return the the data you want to save. The benefit of this is that you can read the previously saved data (good in some scenarios).

Nvm i got confused it alr now though

That makes more sense now, thank you!