Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local HttpService = game:GetService("HttpService")
- local TeleportService = game:GetService("TeleportService")
- local CoreGui = game:GetService("CoreGui")
- local StarterGui = game:GetService("StarterGui")
- local RemoveErrorPrompts = true
- local IterationSpeed = 0.25
- local ExcludefullServers = true
- local SaveTeleportAttempts = false
- local API = "https://games.roblox.com/v1/games/" .. game.PlaceId .. "/servers/Public?limit=100"
- local function notify(txt)
- pcall(function()
- StarterGui:SetCore("SendNotification", {
- Title = "Server Hop",
- Text = txt,
- Duration = 3
- })
- end)
- end
- local function EncodeToFile(JSONString)
- local success, JSONData = pcall(function()
- return HttpService:JSONDecode(JSONString)
- end)
- if not success or not JSONData or not JSONData.data then
- return nil
- end
- JSONData.gameId = game.PlaceId
- local success2, encoded = pcall(function()
- return HttpService:JSONEncode(JSONData)
- end)
- if success2 then
- writefile("Servers.JSON", encoded)
- end
- return JSONData
- end
- local function NextCursor(cursor)
- return game:HttpGet(API ..
- "&excludeFullGames=" .. tostring(ExcludefullServers) ..
- (cursor and "&cursor=" .. cursor or "") ..
- "&_=" .. tick())
- end
- local function StartTeleport()
- local JSONData = EncodeToFile(readfile("Servers.JSON"))
- if not JSONData then
- notify("Refreshing server list...")
- writefile("Servers.JSON", game:HttpGet(API .. "&_=" .. tick()))
- return StartTeleport()
- end
- for i = #JSONData.data, 1, -1 do
- local server = JSONData.data[i]
- if server and server.id ~= game.JobId then
- local JobId = server.id
- table.remove(JSONData.data, i)
- local _, encoded = pcall(function()
- return HttpService:JSONEncode(JSONData)
- end)
- if encoded then
- writefile("Servers.JSON", encoded)
- end
- if SaveTeleportAttempts then
- appendfile("Attempts.txt", JobId .. "\n")
- end
- notify("Trying: "..server.playing.."/"..server.maxPlayers)
- TeleportService:TeleportToPlaceInstance(game.PlaceId, JobId, game.Players.LocalPlayer)
- task.wait(IterationSpeed)
- end
- end
- if JSONData.nextPageCursor then
- notify("Next page...")
- EncodeToFile(NextCursor(JSONData.nextPageCursor))
- StartTeleport()
- else
- notify("Restarting search...")
- writefile("Servers.JSON", game:HttpGet(API .. "&_=" .. tick()))
- StartTeleport()
- end
- end
- local function SetMainPage()
- notify("Loading servers...")
- writefile("Servers.JSON", game:HttpGet(API .. "&_=" .. tick()))
- StartTeleport()
- end
- if RemoveErrorPrompts then
- pcall(function()
- CoreGui:WaitForChild("RobloxGui"):WaitForChild("Modules"):WaitForChild("ErrorPrompt"):Destroy()
- CoreGui:WaitForChild("RobloxPromptGui"):Destroy()
- end)
- end
- if isfile("Servers.JSON") then
- local success, JSONData = pcall(function()
- return HttpService:JSONDecode(readfile("Servers.JSON"))
- end)
- if success and JSONData then
- if JSONData.gameId ~= game.PlaceId then
- notify("Game changed, resetting cache...")
- SetMainPage()
- elseif JSONData.data and #JSONData.data > 0 then
- StartTeleport()
- elseif JSONData.nextPageCursor then
- notify("Fetching more servers...")
- EncodeToFile(NextCursor(JSONData.nextPageCursor))
- StartTeleport()
- else
- SetMainPage()
- end
- else
- SetMainPage()
- end
- else
- SetMainPage()
- end
Advertisement
Comments
-
- Did u rlly have to obfuscate a server hop script
-
- yeah😎
Add Comment
Please, Sign In to add comment