overgrinds

Server Hop

Nov 23rd, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. Time = 1 -- seconds
  2. repeat wait() until game:IsLoaded()
  3. wait(Time)
  4. local PlaceID = game.PlaceId
  5. local AllIDs = {}
  6. local foundAnything = ""
  7. local actualHour = os.date("!*t").hour
  8. local Deleted = false
  9. function TPReturner()
  10.    local Site;
  11.    if foundAnything == "" then
  12.        Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100'))
  13.    else
  14.        Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100&cursor=' .. foundAnything))
  15.    end
  16.    local ID = ""
  17.    if Site.nextPageCursor and Site.nextPageCursor ~= "null" and Site.nextPageCursor ~= nil then
  18.        foundAnything = Site.nextPageCursor
  19.    end
  20.    local num = 0;
  21.    for i,v in pairs(Site.data) do
  22.        local Possible = true
  23.        ID = tostring(v.id)
  24.        if tonumber(v.maxPlayers) > tonumber(v.playing) then
  25.            for _,Existing in pairs(AllIDs) do
  26.                if num ~= 0 then
  27.                    if ID == tostring(Existing) then
  28.                        Possible = false
  29.                    end
  30.                else
  31.                    if tonumber(actualHour) ~= tonumber(Existing) then
  32.                        local delFile = pcall(function()
  33.                            delfile("NotSameServers.json")
  34.                            AllIDs = {}
  35.                            table.insert(AllIDs, actualHour)
  36.                        end)
  37.                    end
  38.                end
  39.                num = num + 1
  40.            end
  41.            if Possible == true then
  42.                table.insert(AllIDs, ID)
  43.                wait()
  44.                pcall(function()
  45.                    writefile("NotSameServers.json", game:GetService('HttpService'):JSONEncode(AllIDs))
  46.                    wait()
  47.                    game:GetService("TeleportService"):TeleportToPlaceInstance(PlaceID, ID, game.Players.LocalPlayer)
  48.                end)
  49.                wait(4)
  50.            end
  51.        end
  52.    end
  53. end
  54.  
  55. function Teleport()
  56.    while wait() do
  57.        pcall(function()
  58.            TPReturner()
  59.            if foundAnything ~= "" then
  60.                TPReturner()
  61.            end
  62.        end)
  63.    end
  64. end
  65.  
  66. -- If you'd like to use a script before server hopping (Like a Automatic Chest collector you can put the Teleport() after it collected everything.
  67. Teleport()
Add Comment
Please, Sign In to add comment