TeleportService not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A way to teleport players when they click a part with tables

  2. What is the issue? Include screenshots / videos if possible!
    I keep getting HTTP 403 Forbidden error
    Screenshot (1395)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have turned on everything, I tried reserving the server, using teleport options, and every single command I could find on the developer hub, I also tried to get a reference code.

I am new to coding btw

local RS = game:GetService(“ReplicatedStorage”)
local RE = RS:WaitForChild(“RemoteEvent”)
local PlaceId = 0
local AmountOfPlayers = 0
local Players = game:GetService(“Players”)
local InQueue = {}
local MouseDetector = workspace.TpThing.ClickDetector
local TeleportService = game:GetService(“TeleportService”)
local ALreadyInTable = false
local reservecode = TeleportService:ReserveServer(PlaceID)

MouseDetector.MouseClick:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

	AmountOfPlayers = AmountOfPlayers + 1	
	local char = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(char)
	for i, OtherPlayer in next, InQueue do
		
		if OtherPlayer == player then
			
			ALreadyInTable = true
			
		end
		
	end
	
	if not ALreadyInTable then
		
	table.insert(InQueue,player.Name)
		
	end
	print(player)
	local TpOption = Instance.new("TeleportOptions")
	TpOption.ShouldReserveServer = true
	wait(5)
	TeleportService:TeleportToPrivateServer(PlaceId,reservecode, InQueue)
end

end)

2 Likes

is the “Allow Third Party Teleports” enabled and enabled in the place you are trying to teleport to? That may be the issue

1 Like

Yes, I thought that was the issue as well but that still gave me that error. P.S. I don’t know if this matters much but this is inside a server script not a local script.

1 Like

Insert the player into the table not the name as you want to teleport the player instance

1 Like

I removed the .Name and I still keep getting the HTTPS error

1 Like

Teleporting can only be done on ROBLOX, not studio.
I altered your code a bit and this only works ingame btw

local PlaceId = 0
local AmountOfPlayers = 0
local Players = game:GetService("Players")
local InQueue = {}
local MouseDetector = script.Parent.ClickDetector
local TeleportService = game:GetService("TeleportService")
local ALreadyInTable = false

MouseDetector.MouseClick:Connect(function(player)
	player = game.Players:FindFirstChild(player.Name)
	if player then
		print("A")
		AmountOfPlayers = AmountOfPlayers + 1	
		for i, OtherPlayer in next, InQueue do

			if OtherPlayer == player then

				ALreadyInTable = true

			end

		end

		if not ALreadyInTable then

			table.insert(InQueue,player)

		end
		print(player)
		local TpOption = Instance.new("TeleportOptions")
		TpOption.ShouldReserveServer = true
		local reservecode = TeleportService:ReserveServer(PlaceId)
		task.wait(5)
		TeleportService:TeleportToPrivateServer(PlaceId,reservecode, InQueue)
	end
end)
2 Likes

Thank you so much I appreciate you and everyone’s help. I just have a quick question, What did you change?

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