AaronSo0908

SWITCH SERVER MODULE

Jan 18th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. function TPReturner()
  2. local Site;
  3. if foundAnything == "" then
  4. Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100'))
  5. else
  6. Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100&cursor=' .. foundAnything))
  7. end
  8. local ID = ""
  9. if Site.nextPageCursor and Site.nextPageCursor ~= "null" and Site.nextPageCursor ~= nil then
  10. foundAnything = Site.nextPageCursor
  11. end
  12. local num = 0;
  13. for i,v in pairs(Site.data) do
  14. local Possible = true
  15. ID = tostring(v.id)
  16. if tonumber(v.maxPlayers) > tonumber(v.playing) then
  17. for _,Existing in pairs(AllIDs) do
  18. if num ~= 0 then
  19. if ID == tostring(Existing) then
  20. Possible = false
  21. end
  22. else
  23. if tonumber(actualHour) ~= tonumber(Existing) then
  24. local delFile = pcall(function()
  25. delfile("NotSameServers.json")
  26. AllIDs = {}
  27. table.insert(AllIDs, actualHour)
  28. end)
  29. end
  30. end
  31. num = num + 1
  32. end
  33. if Possible == true then
  34. table.insert(AllIDs, ID)
  35. wait()
  36. pcall(function()
  37. writefile("NotSameServers.json", game:GetService('HttpService'):JSONEncode(AllIDs))
  38. wait()
  39. game:GetService("TeleportService"):TeleportToPlaceInstance(PlaceID, ID, game.Players.LocalPlayer)
  40. end)
  41. wait(4)
  42. end
  43. end
  44. end
  45. end
  46.  
  47. function switchServer()
  48. while wait() do
  49. pcall(function()
  50. TPReturner()
  51. if foundAnything ~= "" then
  52. TPReturner()
  53. end
  54. end)
  55. end
  56. end
  57.  
Advertisement
Add Comment
Please, Sign In to add comment