kob123678

Server Hopper

Mar 5th, 2023 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer
  2. local Http = game:GetService("HttpService")
  3. local TPS = game:GetService("TeleportService")
  4. local Api = "https://games.roblox.com/v1/games/"
  5.  
  6. local _place,_id = game.PlaceId, game.JobId
  7. local _servers = Api.._place.."/servers/Public?sortOrder=Desc&limit=100"
  8. function ListServers(cursor)
  9. local Raw = game:HttpGet(_servers .. ((cursor and "&cursor="..cursor) or ""))
  10. return Http:JSONDecode(Raw)
  11. end
  12.  
  13. local Next; repeat
  14. local Servers = ListServers(Next)
  15. for i,v in next, Servers.data do
  16. if v.playing < v.maxPlayers and v.id ~= _id then
  17. local s,r = pcall(TPS.TeleportToPlaceInstance,TPS,_place,v.id,Player)
  18. if s then break end
  19. end
  20. end
  21.  
  22. Next = Servers.nextPageCursor
  23. until not Next
Add Comment
Please, Sign In to add comment