MagicalW

Untitled

Mar 8th, 2021 (edited)
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local cfg = getgenv().serverhopsettings or {
  2.     PAGES = 4; --[[If the game is big change this]]
  3.     MAX_PING = 125;
  4. }
  5. local function newserver()
  6.     local rng = Random.new(os.clock())
  7.     local plr = game:GetService("Players").LocalPlayer
  8.     local servers = {}
  9.     for _ = 1,100 do
  10.         for _ = 1, cfg.PAGES do
  11.             local decode = game:GetService("HttpService"):JSONDecode(game:HttpGetAsync("https://games.roblox.com/v1/games/"..game.PlaceId.."/servers/Public?sortOrder=Asc&limit=100&cursor="))
  12.             if decode.nextPageCursor ~= nil then
  13.                 decode = game:GetService("HttpService"):JSONDecode(game:HttpGetAsync("https://games.roblox.com/v1/games/"..game.PlaceId.."/servers/Public?sortOrder=Asc&limit=100&cursor="..decode.nextPageCursor))
  14.                 for _,server in pairs(decode.data) do
  15.                     pcall(function()
  16.                         if server.maxPlayers - server.playing > 1 and server.ping <= cfg.MAX_PING then
  17.                             servers[#servers+1] = server.id
  18.                         end
  19.                     end)
  20.                 end
  21.             else
  22.                 for _,server in pairs(decode.data) do
  23.                     pcall(function()
  24.                         if server.maxPlayers - server.playing > 1 and server.ping <= cfg.MAX_PING then
  25.                             servers[#servers+1] = server.id
  26.                         end
  27.                     end)
  28.                 end
  29.                 break
  30.             end
  31.         end
  32.         pcall(function() game:GetService("TeleportService"):TeleportToPlaceInstance(game.PlaceId, servers[rng:NextInteger(1,#servers)], plr) end)
  33.         wait(8)
  34.     end
  35. end
  36.  
  37. spawn(function()
  38. while wait(0.1) do
  39. local Players = game:GetService("Players")
  40. local LocalPlayer = Players.LocalPlayer
  41.  
  42. for _, v in pairs(Players:GetChildren()) do
  43. local vChar = v.Character or nil if vChar then
  44. local func, result = pcall(function()
  45. local mag = (LocalPlayer.Character.HumanoidRootPart.Position - vChar.HumanoidRootPart.Position).Magnitude
  46. if mag < 2500 and mag ~= 0 --[[distance in studs]] then
  47. newserver()
  48.  
  49.    end
  50. end)
  51. end
  52. end
  53. end
  54. end)
Add Comment
Please, Sign In to add comment