local function try(data,key)
local succ,err = pcall(function()
PlayerData:UpdateAsync(key,function(oldData)
return data
end)
end)
if (succ) then
print('updated')
return true
elseif (not succ or err) then
PlayerData:SetAsync(key,data)
print('save')
return false
end
end
Is there anything to improve?
This is how I call it:
local t = 0
try(dat,p.UserId)
repeat
local result = try(dat,p.UserId)
t +=1
warn(result)
wait(.4)
until t > 3 or result
I want to prevent data loss!