Help With Server Hopper LocalScript

So I’m not really a scripter but I’ve looked at some documentation from Roblox and seen that there are a few ways to server hop, using TeleportService or querying 100 servers at a time.

I’ve tried and prefer to use TeleportService since checking 100 servers per check isn’t enough for me. My TeleportService script always seems to fail. It hops servers, but it just puts me into the same server sometimes or a server that has “restricted access”. Can anyone point me out on how to prevent it from joining full servers and private servers on my game? Thanks.

I know this is really simple stuff but again scripting is not my field, so pointers would be appreciated. :upside_down_face:

Bump, still need help if possible :slight_smile:

Well first, you’re going to need to figure out how many players are in each server:

local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")

function publishPlayerCount()
    local playerCount = #Players:GetPlayers()
    MessagingService:PublishAsync("PlayerCountTopic", playerCount)
end

-- Call this function periodically or when player count changes
Players.PlayerAdded:Connect(publishPlayerCount)
Players.PlayerRemoving:Connect(publishPlayerCount)
-- Also call it initially to set the count
publishPlayerCount()

Now that the other servers know how many players are in that specific server, You can now teleport to that server if the player count doesnt exceed the maximum players allowed in that server