Teleporting players from my game places

  1. What do you want to achieve? I want to teleport players into my game places

  2. What is the issue? The Issue is I keep getting error code 773

  3. What solutions have you tried so far? I tried looking solution for this in DevHub

Heres the code:

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

local TeleportId = 108993884735173

local TransitionEvent = ReplicatedStorage:WaitForChild("RemoteEvents").TransitionEvent
local ExitEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ExitEvent

local Gate = script.Parent:WaitForChild("Gate")

local Frame = Gate:WaitForChild("SurfaceGui").Frame
local PlayerNumber = Frame:WaitForChild("PlayerNumber")
local TimeNumber = Frame:WaitForChild("TimeNumber")
local TeleportLabel = Frame:WaitForChild("TeleportLabel")

local PlayersTable = {}
local Timer
local IsTeleporting = false
local PlayersAllowed = script:WaitForChild("PlayersAllowed")

function Refresh()

	PlayerNumber.Text = #PlayersTable
end

local function RemoveFromList(Character)

	for i = 1, #PlayersTable do

		if PlayersTable[i] == Character.Name then

			table.remove(PlayersTable, i)

			Refresh()
		end
	end
end

local function Teleport()

	if #PlayersTable > 0 then

		local TeleportPlayers = {}

		for i = 1, #PlayersTable do

			if Players:FindFirstChild(PlayersTable[i]) then

				table.insert(TeleportPlayers, Players:FindFirstChild(PlayersTable[i]))

				TransitionEvent:FireClient(Players:FindFirstChild(PlayersTable[i]))

				TeleportLabel.Text = "TELEPORTING"
				TeleportLabel.TextColor3 = Color3.fromRGB(255, 70, 0)

			else

				table.remove(PlayersTable, i)
			end
		end

		local Code = TeleportService:ReserveServer(TeleportId)

		IsTeleporting = true
		TeleportService:TeleportToPrivateServer(TeleportId, Code, TeleportPlayers)

		repeat wait() until #PlayersTable <= 0

		IsTeleporting = false
	end
end

Gate.Touched:Connect(function(Hit)

	if Hit and Hit.Parent:FindFirstChild("Humanoid") then

		if IsTeleporting == false then

			local Player = Players:GetPlayerFromCharacter(Hit.Parent)
			local Character = Player.Character or Player.CharacterAdded:Wait()

			local InsideGate = false

			for i = 1, #PlayersTable do

				if PlayersTable[i] == Character.Name then

					InsideGate = true
				end
			end

			if InsideGate == false and #PlayersTable < PlayersAllowed.Value then
				
				table.insert(PlayersTable, Character.Name)
				
				Character:FindFirstChild("HumanoidRootPart").CFrame = Gate.CFrame + Vector3.new(0, 0, -10)
				Character:FindFirstChild("Humanoid").JumpHeight = 0
				
				Refresh()
				
				ExitEvent:FireClient(Player)
				
				Player.CharacterRemoving:Connect(function(Character)
					
					RemoveFromList(Character)
				end)
			end
		end
	end
end)

ExitEvent.OnServerEvent:Connect(function(Player: Player)

	if Player.Character or Player.CharacterAdded:Wait() then

		local Humanoid = Player.Character:FindFirstChild("Humanoid")

		if Humanoid then
			
			Player.Character:FindFirstChild("HumanoidRootPart").CFrame = Gate.CFrame + Vector3.new(0, 0, 12)

			RemoveFromList(Player.Character)
		end

		Humanoid.JumpHeight = 7.2
	end
end)

while task.wait() do

	Timer = 30

	TeleportLabel.Text = "READY"
	TeleportLabel.TextColor3 = Color3.fromRGB(160, 255, 0)

	for i = 1, Timer do

		Timer = Timer - 1
		TimeNumber.Text = Timer

		task.wait(1)
	end

	Teleport()
end

-- Code not mine --

Hello!

I think this issue is happening because you’re trying to teleport the player between places that are not from the same universe. If this is not the case, make sure both places are published. If this doesn’t work, try making the place public. If neither of the two options works, make sure the place ID you wrote is correct,

Thanks!

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