Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Reasons for failure pcall on UpdateAsync()?

Asked by 7 years ago
Edited 7 years ago

In solo mode(not online mode), does pcall return false with :UpdateAsync at all times?


local success, message = pcall(PlayerData:UpdateAsync(key, function(oldValue) return Data end))

This could mess up my datastore system where I forceload any missing data and try to revive the player's data.

It states it's a failure but the data is successfully stored..

1 answer

Log in to vote
0
Answered by 7 years ago

You are pcalling the value returned by PlayerData:UpdateAsync, not the function call itself. To correct this, simply create an anonymous function for use by pcall:

local success, message = pcall(function()
    PlayerData:UpdateAsync(key, function(oldValue)
        return Data
    end)
end)
Ad

Answer this question