Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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


1 comment

0

Weirdly it still doesn't work! Below is what I did

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


This discussion is preserved as it was. New answers, comments, and votes are closed.