this is the script that i use: local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local zone1 = workspace.zone1 -- Ensure this part is named correctly
local privateServerId = 127274423977034 -- Your private server ID
local code = TeleportService:ReserveServer(privateServerId) -- Reserve a new server
-- Function to teleport all players in the zone to the private server
local function teleportAllPlayersInZone()
local playersInZone = {} -- Table to hold all players currently in the zone
for _, player in pairs(Players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local characterPosition = player.Character.HumanoidRootPart.Position
-- Check if the player is within the bounds of zone1 (adjust as necessary)
if (zone1.Position - characterPosition).Magnitude < zone1.Size.Magnitude / 2 then
table.insert(playersInZone, player) -- Add to the table if they're in the zone
end
end
end
-- Teleport all players found in the zone to the private server
if #playersInZone > 0 then
TeleportService:TeleportToPrivateServer(privateServerId, code, playersInZone)
print("Teleported players to private server:", #playersInZone) -- Log the number of players teleported
end
end
local function onPlayerTouch(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent) -- Get the player from the character
if player then
wait(5) -- Wait for 5 seconds before teleporting players
teleportAllPlayersInZone() -- Call the function to teleport all players in the zone
end
end
zone1.Touched:Connect(onPlayerTouch)
but i dont want other player to be able to join the same place like private serveur else then if you are in the zone1 at the same time
** You are now Level 5! **