How Would I Change This Script So All Players in Server Are Teleported to a RESERVED Server?

I would like to create a ROBLOX Mimic-like teleport feature (that teleports all players in server to a reserved server when they touch a certain part [when the player has reached the end of part 1, they get to part 2])

The problem is that if two servers are on part 1, and both reach part 2, they will meet eachother and possibly (high chance) crash/break the game.

I’m stuck, even after getting help on reserved teleporting, and I cannot find any solutions.

Anything would help, thanks!

Code:

local TeleportService = game:GetService('TeleportService')
local players = game:GetService("Players")
local part2GameId = 0

script.Parent.Touched:Connect(function(otherPart)
	if otherPart.Parent:FindFirstChildWhichIsA("Humanoid") then
		local player = players:GetPlayerFromCharacter(otherPart.Parent)
		
		local success, result = pcall(function()
			return TeleportService:TeleportPartyAsync(part2GameId, players:GetChildren())	
		end)
		if not success then
			warn(result)
		end
		
	end
end)
2 Likes

You can use

local reservedServerCode = TeleportService:ReserveServer(game.PlaceId)

to get a reserved server id

TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })

to tp players to the reserved server

2 Likes

Thank you very much, works perfectly!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.