Advertisement
Guest User

Example for RequestService

a guest
Jul 30th, 2022
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local RequestService = game:GetService("ServerStorage"):WaitForChild("RequestService")
  2. local DSS = game:GetService("DataStoreService")
  3. local ThisDS = DSS:GetDataStore("Example")
  4.  
  5. local RequestInformationRemoteFunction = ...
  6.  
  7. function RequestInfo(plr,key)
  8.     local info
  9.     --
  10.     local canPlrProceed = RequestService:RequestToProceed("GetInfo", 6, plr.UserId)
  11.     if canPlrProceed and KeyIsLegit(key) then
  12.         local success, response = pcall(function()
  13.             ThisDS:UpdateAsync(key, function(pastData)
  14.                 info = pastData        
  15.             end)            
  16.         end)
  17.         --
  18.         if not success then
  19.             print(response)
  20.             info = "Pcall failed!"
  21.         end
  22.     else
  23.         if not canPlrProceed then
  24.             info = "You cannot get information yet. Please wait!"
  25.         else
  26.             info = "Unsupported key for datastores!"
  27.         end
  28.     end
  29.     --
  30.     return info
  31. end
  32.  
  33. RequestInformationRemoteFunction.OnServerInvoke = RequestInfo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement