#script serverscript service teleportservice

1 messages · Page 1 of 1 (latest)

abstract laurel
#

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

rare hollyBOT
#

studio** You are now Level 5! **studio

abstract laurel
#

and i have no idea if someone could tell me how or make me de script it would be apéciated it been 3 days that im hard stuck

ancient timber
#

please format it to lua please

abstract laurel
#

what do you mean

#

a screen?

astral dawn
abstract laurel
#

i know

astral dawn
#

You should make your scripts by yourself

abstract laurel
#

i did but wasent working so try with him didnt work to

astral dawn
#

Thats even worse

#

I have a tip for you

#

Delete this script and make another one from scratch with your knowledge

#

And when your blocked just come here and ask your questions