local TeleportService = game:GetService("TeleportService") local HttpService = game:GetService("HttpService") local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local StarterGui = game:GetService("StarterGui") -- Tạo GUI để hiển thị trạng thái local function createGui() local screenGui = Instance.new("ScreenGui") screenGui.Name = "ServerStatusGui" screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") screenGui.ResetOnSpawn = false local textLabel = Instance.new("TextLabel") textLabel.Size = UDim2.new(0, 400, 0, 60) textLabel.Position = UDim2.new(0.5, -200, 0, 10) textLabel.BackgroundTransparency = 0.5 textLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0) textLabel.TextColor3 = Color3.fromRGB(255, 255, 255) textLabel.TextSize = 18 textLabel.TextWrapped = true textLabel.Text = "Đang khởi tạo..." textLabel.Parent = screenGui return textLabel end local statusLabel = createGui() local checkCount = 0 local apiFailCount = 0 local lastCheckTime = 0 -- Hàm cập nhật trạng thái GUI local function updateStatus(message) print(message) statusLabel.Text = message .. "\n(Lần kiểm tra: " .. checkCount .. " | API fail: " .. apiFailCount .. " | Thời gian: " .. os.date("%H:%M:%S") .. ")" end -- Hàm kiểm tra và dịch chuyển đến server rỗng local function checkAndTeleport() while true do checkCount = checkCount + 1 local currentTime = tick() if currentTime - lastCheckTime < 3 then wait(3 - (currentTime - lastCheckTime)) end -- Đảm bảo 3 giây giữa các kiểm tra lastCheckTime = currentTime updateStatus("Đang kiểm tra danh sách server...") local success, result = pcall(function() return HttpService:JSONDecode(game:HttpGet("https://games.roblox.com/v1/games/" .. game.PlaceId .. "/servers/Public?sortOrder=Asc&limit=100")) end) if success and result and result.data then apiFailCount = 0 -- Reset khi API thành công local foundEmpty = false for _, server in pairs(result.data) do if server.playing == 0 then foundEmpty = true updateStatus("Tìm thấy server rỗng: " .. server.id) local teleportSuccess, teleportError = pcall(function() TeleportService:TeleportToPlaceInstance(game.PlaceId, server.id, LocalPlayer) end) if teleportSuccess then updateStatus("Đang dịch chuyển đến server rỗng: " .. server.id) wait(5) return -- Dừng script sau khi join else updateStatus("Lỗi khi dịch chuyển: " .. teleportError .. ". Tiếp tục kiểm tra...") end end end if not foundEmpty then updateStatus("Chưa tìm thấy server rỗng, tiếp tục kiểm tra...") end else apiFailCount = apiFailCount + 1 updateStatus("Lỗi khi lấy danh sách server: " .. (result or "API thất bại (có thể rate limit hoặc executor)") .. ". Thử lại...") wait(5) -- Thử lại ngay nếu fail end end end -- Hàm tự động khởi động lại nếu bị ngắt local function startScript() while true do local co = coroutine.create(checkAndTeleport) coroutine.resume(co) wait(10) -- Chờ 10 giây trước khi thử lại nếu coroutine fail end end -- Khởi động script coroutine.resume(coroutine.create(startScript))