Best Ping Server Finder
Key RequiredUniversal

Best Ping Server Finder

Universal Scriptchayoochayoo 1.2K views 1.5K executesUpdated Apr 2, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•252 lines (6400 chars)
--[[
    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

Features & Information

Features: • Auto-joins lowest ping server • Configurable player count (min/max) • Max ping filter • Skips full & empty servers • Multi-page API fetching • Fallback filters if no match • No simulation - real API data Settings: • MIN_PLAYERS = 10 • MAX_PLAYERS = 15 • MAX_PING = 200ms • MAX_SERVERS = 100

Community Comments (3)

BurmaldaBurmaldaApr 6, 2026

very good script thank you broski

Replying to @Burmalda
chayoochayooApr 22, 2026

@Burmalda no problem dude<3

nurliawatiyeni7nurliawatiyeni7Apr 24, 2026

WOW very good script ping Oh?

More Scripts for Universal Scripts