Guest User

GettingDataExample

a guest
Aug 12th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local function get_data(player_id, tries)
  2.    
  3.     tries = tries or 0
  4.    
  5.     if tries ~= 3 then
  6.        
  7.         local success, data
  8.        
  9.         if data_store_service:GetRequestBudgetForRequestType(get_async_enum) > 0 then
  10.             success, data = pcall(main_data_store.GetAsync, main_data_store, player_id)
  11.         else
  12.            
  13.             repeat
  14.                 wait(1)
  15.             until data_store_service:GetRequestBudgetForRequestType(get_async_enum) > 0
  16.            
  17.             success, data = pcall(main_data_store.GetAsync, main_data_store, player_id)
  18.            
  19.         end
  20.        
  21.         if success then
  22.             return data
  23.         else
  24.            
  25.             warn(
  26.                 "Failure to load "..player_id.."'s data on try: "..tries..".",
  27.                 "\n",
  28.                 "Error: "..data
  29.             )
  30.            
  31.             tries = tries + 1
  32.             wait(7)
  33.             return get_data(player_id, tries)
  34.            
  35.         end
  36.        
  37.     else
  38.         return "ERROR"
  39.     end
  40.    
  41. end
Advertisement
Add Comment
Please, Sign In to add comment