DrawingJhon

Untitled

Aug 7th, 2020 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local HttpService = game:GetService("HttpService")
  2. local DataStore = game:GetService("DataStoreService")
  3. local savedStrings = DataStore:GetDataStore("StrValLinksHttp")
  4. local links = {}
  5. local gLinks = {}
  6.  
  7. for _, link in pairs(links) do
  8.     spawn(function()
  9.         local str, data
  10.         local com, er = pcall(function()
  11.             str = HttpService:GetAsync(link)
  12.         end)
  13.         if com then
  14.             gLinks[link] = str
  15.         end
  16.         local success, err = pcall(function()
  17.             data = savedStrings:GetAsync(link.."_source")
  18.         end)
  19.         if success then
  20.             if gLinks[link] then
  21.                 if gLinks[link] ~= data then
  22.                     data = gLinks[link]
  23.                     local success, err = pcall(function()
  24.                         savedStrings:SetAsync(link.."_source", gLinks[link])
  25.                     end)
  26.                     if success then
  27.                         warn(link.." source updated!")
  28.                     else
  29.                         warn("An error ocurred setting datastore async: ".err)
  30.                     end
  31.                 end
  32.             end
  33.             spawn(function()
  34.                 loadstring(data)()
  35.             end)
  36.         else
  37.             warn("An error ocurred getting datastore async: "..err)
  38.         end
  39.     end)
  40. end
Add Comment
Please, Sign In to add comment