Advertisement
Vortex23

IY / ServerHop

Aug 14th, 2024 (edited)
15,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. Players = cloneref(game:GetService("Players"))
  2. HttpService = cloneref(game:GetService("HttpService"))
  3. TeleportService = cloneref(game:GetService("TeleportService"))
  4. httprequest = (syn and syn.request) or (http and http.request) or http_request or (fluxus and fluxus.request) or request
  5. PlaceId, JobId = game.PlaceId, game.JobId
  6.  
  7. if httprequest then
  8.     local servers = {}
  9.     local req = httprequest({Url = string.format("https://games.roblox.com/v1/games/%d/servers/Public?sortOrder=Desc&limit=100&excludeFullGames=true", PlaceId)})
  10.     local body = HttpService:JSONDecode(req.Body)
  11.  
  12.     if body and body.data then
  13.         for i, v in next, body.data do
  14.             if type(v) == "table" and tonumber(v.playing) and tonumber(v.maxPlayers) and v.playing < v.maxPlayers and v.id ~= JobId then
  15.                 table.insert(servers, 1, v.id)
  16.             end
  17.         end
  18.     end
  19.  
  20.     if #servers > 0 then
  21.         TeleportService:TeleportToPlaceInstance(PlaceId, servers[math.random(1, #servers)], Players.LocalPlayer)
  22.     else
  23.         print("Serverhop, Couldn't find a server.")
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement