Problem with teleport player to other places

I’m trying make a Gui Button, that take the player to a other place, it’s my first time making this so I used a Roblox Script Teleporting Between Places (roblox.com) but didn’t worked.

Module Script -

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

local TeleportModule = {}

local RETRY_DELAY = 2
local MAX_WAIT = 10

local teleportEvent = script.Parent:WaitForChild("TeleportEvent")

function TeleportModule.teleportWithRetry(targetPlaceID, playersTable, teleportOptions)
local currentWait = 0

teleportEvent:FireAllClients(playersTable, true)

local function doTeleport(players, options)
	if currentWait < MAX_WAIT then
		local success, errorMessage = pcall(function()
			return TeleportService:TeleportAsync(targetPlaceID, players, options)
		end)
		if not success then
			warn(errorMessage)
			wait(RETRY_DELAY)
			currentWait = currentWait + RETRY_DELAY
			doTeleport(players, teleportOptions)
		end
	else
		teleportEvent:FireAllClients(players, false)
		return true
	end
end

TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage)
	if teleportResult ~= Enum.TeleportResult.Success then
		warn(errorMessage)
		wait(RETRY_DELAY)
		currentWait = currentWait + RETRY_DELAY
		doTeleport({player}, teleportOptions)
	end
end)
doTeleport(playersTable, teleportOptions)
end

return TeleportModule

Local Script - Gui Button

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local button = script.Parent
local targetPlaceID = 123("my real place id here, but i didn't add in the post")

local teleportEvent = ReplicatedStorage:WaitForChild("TeleportEvent")

button.MouseButton1Click:Connect(function()
teleportEvent:FireServer(targetPlaceID)
end)

Thanks

Getting the obvious away Are Third Party Teleports & API Services enabled in your Game Settings? Also you could just get the TeleportService from the client & teleport the player using the same PlaceID that way

1 Like

Yes it’s enabled.
And how I can make this, u saying(2+ lines)?

If you’re talking about the message thingy just hit enter lol

I believe you can do it like this from your Local Standpoint:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local button = script.Parent
local TPService = game:GetService("TeleportService")
local targetPlaceID = 123 --Whatever it is

local teleportEvent = ReplicatedStorage:WaitForChild("TeleportEvent")

button.MouseButton1Click:Connect(function()
    TPService:Teleport(targetPlaceID)
end)
1 Like