Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local HttpService = game:GetService("HttpService")
- local TeleportService = game:GetService("TeleportService")
- local Players = game:GetService("Players")
- -- Configuration
- local placeId = game.PlaceId
- local maxPlayersLimit = _G.ServerPlayers or 10 -- Default to 10 if _G.ServerPlayers is not set
- -- Function to hop to a different server
- local function serverHop()
- -- Fetch list of servers
- local url = "https://games.roblox.com/v1/games/" .. placeId .. "/servers/Public?sortOrder=Asc&limit=100"
- local success, response = pcall(function()
- return HttpService:HttpGet(url)
- end)
- if not success then
- warn("Failed to fetch servers: " .. response)
- return
- end
- -- Parse server data
- local servers = HttpService:JSONDecode(response).data
- for _, server in pairs(servers) do
- if server.playing > maxPlayersLimit and server.playing < server.maxPlayers then
- -- Teleport to the found server
- TeleportService:TeleportToPlaceInstance(placeId, server.id)
- print("Teleporting to server with ID:", server.id)
- return
- end
- end
- print("No suitable server found.")
- end
- -- Main logic
- if placeId == 15297128281 then
- if #Players:GetPlayers() <= maxPlayersLimit then
- serverHop()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment