--[[ Auto Server Joiner v3 Automatically joins the best server based on: - Lowest ping (priority) - Player count within range (MIN - MAX) - Not full - Not current server ]] local Players = game:GetService("Players") local HttpService = game:GetService("HttpService") local TeleportService = game:GetService("TeleportService") local StarterGui = game:GetService("StarterGui") local LocalPlayer = Players.LocalPlayer local PlaceId = game.PlaceId local CurrentJobId = game.JobId -- CONFIGURATION (You can change these) local CONFIG = { MIN_PLAYERS = 10, -- Minimum players in server MAX_PLAYERS = 15, -- Maximum players in server MAX_SERVERS = 100, -- How many servers to fetch MAX_PING = 200, -- Maximum ping allowed (ms) PAGES = 3, -- How many pages to fetch } -- FUNCTIONS local function Notify(title, text, duration) pcall(function() StarterGui:SetCore("SendNotification", { Title = title, Text = text, Duration = duration or 4 }) end) end local function HttpGet(url) if request then local ok, result = pcall(function() local resp = request({ Url = url, Method = "GET", Headers = { ["Accept"] = "application/json", } }) return resp.Body end) if ok and result then return result end end local ok, result = pcall(function() return game:HttpGet(url) end) if ok then return result end return nil end local function FetchAllServers() local allServers = {} local cursor = nil local pageCount = 0 while pageCount < CONFIG.PAGES do pageCount = pageCount + 1 local url = string.format( "https://games.roblox.com/v1/games/%s/servers/public?sortOrder=Asc&limit=%d", PlaceId, CONFIG.MAX_SERVERS ) if cursor then url = url .. "&cursor=" .. cursor end local response = HttpGet(url) if not response then break end local ok, data = pcall(function() return HttpService:JSONDecode(response) end) if not ok or not data or not data.data then break end for _, server in ipairs(data.data) do table.insert(allServers, server) end if data.nextPageCursor then cursor = data.nextPageCursor else break end task.wait(0.2) end return allServers end -- MAIN LOGIC print("[Joiner] Configuration:") print("[Joiner] MIN_PLAYERS: " .. CONFIG.MIN_PLAYERS) print("[Joiner] MAX_PLAYERS: " .. CONFIG.MAX_PLAYERS) print("[Joiner] MAX_PING: " .. CONFIG.MAX_PING .. " ms") print("[Joiner] MAX_SERVERS: " .. CONFIG.MAX_SERVERS) Notify("Auto Joiner", "Searching for best server...", 3) local allServers = FetchAllServers() print("[Joiner] Fetched " .. #allServers .. " servers") if #allServers == 0 then print("[Joiner] ERROR: No servers found") Notify("Auto Joiner", "Failed to fetch servers!", 5) return end -- Filter servers local filtered = {} for _, server in ipairs(allServers) do local id = server.id local playing = server.playing or 0 local maxP = server.maxPlayers or 0 local ping = server.ping or 999 -- Skip current server if id == CurrentJobId then continue end -- Skip full servers if playing >= maxP then continue end -- Skip too empty if playing < CONFIG.MIN_PLAYERS then continue end -- Skip too many players if playing > CONFIG.MAX_PLAYERS then continue end -- Skip high ping if ping > CONFIG.MAX_PING then continue end table.insert(filtered, server) end print("[Joiner] Filtered: " .. #filtered .. " servers match criteria") if #filtered == 0 then print("[Joiner] No servers match criteria, relaxing filters...") -- Try again with relaxed ping for _, server in ipairs(allServers) do local id = server.id local playing = server.playing or 0 local maxP = server.maxPlayers or 0 local ping = server.ping or 999 if id ~= CurrentJobId and playing >= CONFIG.MIN_PLAYERS and playing <= CONFIG.MAX_PLAYERS and playing < maxP then table.insert(filtered, server) end end print("[Joiner] Relaxed filter: " .. #filtered .. " servers") end if #filtered == 0 then print("[Joiner] Still no servers, trying any non-full server...") for _, server in ipairs(allServers) do local id = server.id local playing = server.playing or 0 local maxP = server.maxPlayers or 0 if id ~= CurrentJobId and playing < maxP and playing >= 5 then table.insert(filtered, server) end end print("[Joiner] Final filter: " .. #filtered .. " servers") end -- Sort by ping (lowest first) table.sort(filtered, function(a, b) return (a.ping or 999) < (b.ping or 999) end) -- Best server local best = filtered[1] if best then local ping = best.ping or 0 local playing = best.playing or 0 local maxPlayers = best.maxPlayers or 0 print("[Joiner] BEST SERVER FOUND") print("[Joiner] Ping: " .. ping .. " ms") print("[Joiner] Players: " .. playing .. "/" .. maxPlayers) print("[Joiner] ID: " .. best.id) Notify( "Auto Joiner", "Server found!\n" .. "Ping: " .. ping .. " ms\n" .. "Players: " .. playing .. "/" .. maxPlayers, 5 ) task.wait(1) local joinOk, joinErr = pcall(function() TeleportService:TeleportToPlaceInstance(PlaceId, best.id, LocalPlayer) end) if joinOk then print("[Joiner] Teleport successful!") else print("[Joiner] ERROR: Teleport failed - " .. tostring(joinErr)) Notify("Auto Joiner", "Join failed: " .. tostring(joinErr), 5) end else print("[Joiner] No suitable server found") print("[Joiner] Total servers checked: " .. #allServers) Notify("Auto Joiner", "No suitable server found!", 5) end