xvc200

Server Hop Script

Feb 13th, 2025 (edited)
19,057
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local HttpService = game:GetService("HttpService")
  3.  
  4. local PlaceID = game.PlaceId
  5. local ServerListURL = "https://games.roblox.com/v1/games/" .. PlaceID .. "/servers/Public?sortOrder=Asc&limit=100"
  6.  
  7. function GetRandomServer()
  8. local success, result = pcall(function()
  9. return HttpService:JSONDecode(game:HttpGet(ServerListURL))
  10. end)
  11.  
  12. if success and result and result.data then
  13. local randomServer = result.data[math.random(1, #result.data)]
  14. if randomServer.playing < randomServer.maxPlayers and randomServer.id ~= game.JobId then
  15. return randomServer.id
  16. end
  17. end
  18.  
  19. return nil
  20. end
  21.  
  22. local NewServerID = GetRandomServer()
  23.  
  24. if NewServerID then
  25. TeleportService:TeleportToPlaceInstance(PlaceID, NewServerID, game.Players.LocalPlayer)
  26. else
  27. game:GetService("StarterGui"):SetCore("SendNotification", {
  28. Title = "Server Hop",
  29. Text = "Couldn't find a server!",
  30. Duration = 5,
  31. Icon = "rbxassetid://76020773425692"
  32. })
  33. end
Advertisement
Comments
Add Comment
Please, Sign In to add comment