Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My Server Teleport Script Doesn't Work For Some Reason? (Re-Upload)

Asked by 2 years ago

My script to teleport people to a reserved server of a sub-game isn't working:

while true do
    print("Running")
 wait()
    local TS = game:GetService("TeleportService")
    local Players = game:GetService("Players")
    local code = TS:ReserveServer(8357468682)
    local players = Players:GetPlayers()
    TS:TeleportToPrivateServer(8357468682,code,players)
end

It's a normal script in workspace, I'm so confused

2 answers

Log in to vote
0
Answered by
Nefarioum 162
2 years ago

ReserveServer & TeleportToPrivateServers are both functions that are not recommended to be used anymore. ROBLOX has released a more recent multi-use function in TeleportService called TeleportAsync (DevWiki) which should be used instead.

Here is a revised version of your code which uses it and should work. Note that I would not recommend using a while loop as it will constantly just teleport them. Put it in a function and call it when you need it.

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

while true do
    print("Running")
    wait()
    local teleportOptions = Instance.new("TeleportOptions")
    teleportOptions.ShouldReserveServer = true

    local players = Players:GetPlayers()

    if #players >= 1 then       
        local teleportResult = TeleportService:TeleportAsync(game.PlaceId, players , teleportOptions);

        -- print(teleportResult.ReservedServerAccessCode);  -- You can access the reserved server access code using this.
    end
end


0
Weirdly it still doesn't work! Below is what I did User#39520 0 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

So I modified game.PlaceId to my sub-place is what I call it (8357468682) yet it still doesn't work! I put it in a normal script in workspacee and this is the error I got

" 11:32:27.874 HTTP 403 (Forbidden) - Server - Script:13"

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

while true do
    print("Running")
    wait()
    local teleportOptions = Instance.new("TeleportOptions")
    teleportOptions.ShouldReserveServer = true

    local players = Players:GetPlayers()

    if #players >= 1 then       
        local teleportResult = TeleportService:TeleportAsync(8357468682, players , teleportOptions);

        -- print(teleportResult.ReservedServerAccessCode);  -- You can access the reserved server access code using this.
    end
end


Answer this question