I've already asked the dev of the studio I'm in and we couldn't figure it out. Anyway, Every time, it prints the error (errorMsg from pcall arg). The key is the players ID (not number but string) and CoinValue is a number. I've already SetAsync it so it's a valid datastore entry.
Players.PlayerRemoving:Connect(function(player)
local CoinValue = PlayerCoins:FindFirstChild(tostring(player.UserId))
print(CoinValue.Value)
local CoinStore = DataStoreService:GetDataStore("CoinStore")
local key = tostring(player.UserId)
local success, errorMsg = pcall(function()
CoinStore:UpdateAsync(key,CoinValue.Value)
end)
if success then
print("yay")
print(success)
elseif errorMsg then
print("nope")
print(success)
end
end)

1 comment
Tried that, neither the print under success or else message prints