MaxproGlitcher

Serverhop.lua

Dec 23rd, 2025 (edited)
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. local API, HttpService, TeleportService, CoreGui = nil, game:GetService("HttpService"), game:GetService("TeleportService"), game:GetService("CoreGui");
  2. local RemoveErrorPrompts = true --prevents error messages from popping up.
  3. local IterationSpeed = 0.25 --speed in which next server is picked for teleport (the higher it is the slower the teleports but more likely to work).
  4. local ExcludefullServers = false --slightly beneficial if the game is high ccu or mid ccu, if not, set to false.
  5. local SaveTeleportAttempts = false --saves every teleports that are attempted in jobid to "Attempts.txt" file
  6.  
  7. local function EncodeToFile(JSONString)
  8. local success, JSONData = pcall(function()
  9. return HttpService:JSONDecode(JSONString)
  10. end)
  11. if success and JSONData.data then
  12. JSONData.gameId = game.PlaceId
  13. local success, encoded = pcall(function()
  14. return HttpService:JSONEncode(JSONData)
  15. end)
  16. if success then
  17. writefile("Servers.JSON", encoded)
  18. else
  19. error("Failed to encode JSON string.")
  20. return
  21. end
  22. else
  23. error("Failed to decode JSONData.")
  24. return
  25. end
  26. return JSONData
  27. end
  28.  
  29. local function NextCursor(ep)
  30. return game:HttpGet(API .. "&excludeFullGames=" .. tostring(ExcludefullServers) .. ((ep and "&cursor=" .. ep) or ""))
  31. end
  32.  
  33. local function StartTeleport()
  34. local JSONData = EncodeToFile(readfile("Servers.JSON"))
  35. for i = 0, 99 do
  36. if #JSONData.data <= 1 then
  37. EncodeToFile(NextCursor(JSONData.nextPageCursor))
  38. TeleportService:Teleport(game.PlaceId, game.Players.LocalPlayer)
  39. end
  40. if JSONData.data[i] then
  41. local JobId = JSONData.data[i].id
  42. table.remove(JSONData.data, i)
  43. local sucess, encoded = pcall(function()
  44. return HttpService:JSONEncode(JSONData)
  45. end)
  46. writefile("Servers.JSON", encoded)
  47. if SaveTeleportAttempts then
  48. appendfile("Attempts.txt", JobId .. "\n")
  49. end
  50. TeleportService:TeleportToPlaceInstance(game.PlaceId, JobId, game.Players.LocalPlayer)
  51. task.wait(IterationSpeed)
  52. end
  53. end
  54. end
  55.  
  56. local function SetMainPage()
  57. local MainPage = game:HttpGet(API)
  58. writefile("Servers.JSON", MainPage)
  59. StartTeleport()
  60. end
  61.  
  62. API = "https://games.roblox.com/v1/games/" .. game.PlaceId .. "/servers/Public?limit=100"
  63.  
  64. if RemoveErrorPrompts then CoreGui:WaitForChild("RobloxGui"):WaitForChild("Modules"):WaitForChild("ErrorPrompt"):Destroy() CoreGui.RobloxPromptGui:Destroy() end
  65.  
  66. if isfile("Servers.JSON") then
  67. local success, JSONData = pcall(function()
  68. return HttpService:JSONDecode(readfile("Servers.JSON"))
  69. end)
  70. if success and JSONData then
  71. if JSONData.gameId ~= game.PlaceId then
  72. warn("Game mismatch from cache, remaking cache for --> " .. game.PlaceId)
  73. SetMainPage()
  74. end
  75. if JSONData.data and #JSONData.data >= 1 then
  76. StartTeleport()
  77. else
  78. if success and JSONData.nextPageCursor then
  79. EncodeToFile(NextCursor(JSONData.nextPageCursor))
  80. StartTeleport()
  81. else
  82. SetMainPage() --no more pages left, start over
  83. end
  84. end
  85. else
  86. SetMainPage()
  87. end
  88. else
  89. SetMainPage()
  90. end
Advertisement
Add Comment
Please, Sign In to add comment