I dont understand how the update async works heres the code i got from the wiki

local ds = game:GetService("DataStoreService"):GetDataStore("PlayeData") -- Name the DataStore whenever you like!
game.Players.PlayerRemoving:Connect(function(plr)
    local key = "plr-"..plr.UserId -- Use UserId instead of the player's name because the player's name may change overtime!
    ds:UpdateAsync(key, function(oldvalue) -- Imagine the value is a number...
        local newvalue = oldvalue + 100 or 10 -- just to make sure that oldvalue isn't new, or else just treat it as 10.
        return newvalue -- Returns and updates the value!
    end)
end

WHERE DID oldvalue COME FROM I DONT UNDERSTAND ITS NOT DEFINED EXCEPT FOR THE FUNCTION I also dont understand the function(oldvalue) it does not have connect or anything in it? How does that work?

2 comments

0

UpdateAsync is just a function with two parameters, a key that is a string, and a transform function with a built in parameter that is set to the old value of the key

0

It doesn't need Connect , as it isn't an event