How to teleport players to the same place, but random different server

Hey there, I am trying to send the player to a random server, in the same place / game when a function is called.

I see some tutorials here in the forum where either they attempt to send the player to a different place, or send them to a specific server instance. Is there any way to just random rejoin them in a random open server?

Thanks

1 Like

That should work

--Serversided script if u want me to make a client sided one i can make.
local HttpService = game:GetService("HttpService")
local TeleportService = game:GetService("TeleportService")

local function Hop(Player)
	local servers = HttpService:GetAsync("https://games.roproxy.com/v1/games/" .. game.PlaceId .. "/servers/Public?sortOrder=Asc&limit=100")
	local decoded = HttpService:JSONDecode(servers.data)
	
	local ServerJobIds = {}
	
	local Rand = Random.new(tick())
	
	for i, v in ipairs(decoded) do
		if v.id ~= game.JobId then
			ServerJobIds[#ServerJobIds + 1] = v.id
		end
	end
    local bool = #ServerJobIds ~= 0
    assert(bool,"Couldnt find servers more than one")
	local random = Rand:NextInteger(1,#ServerJobIds)
	
	TeleportService:TeleportToPlaceInstance(game.PlaceId,ServerJobIds[random],Player)
end

If this doesnt work, tell me. I made this without testing.

oh so roproxy doesnt support .games so i gonna remake it.

welll if u find a proxy it will work i also tried using messaging service for getting every games job id but it didnt work so idk how to make it without a proxy.

Is there any like “Reconnect” type of thing? I just want to make sure they dont join the same server

it has a check for it also when founded servers are 1 it gives error its the assert()
oh wait lemme add the assert()
ok i did u can check the script again

image
I get this error @boris_uresin

it doesnt work since roproxy doesnt support .games