[SIMPLE] Issue with teleporting

Hello.
Why does this script not work:

	while game.Players:FindFirstChild(player.Name) do
		local success, errorMessage = pcall(function()
			-- lets get serverDataStore, and that is the serverAccessCode
			local serverAccessCode = serverDataStore:GetAsync(friendId) -- who we're joining

			local tpData={
				ReservedServerCode=serverAccessCode
			}
			print(serverAccessCode)
			--TeleportService:TeleportToPlaceInstance(17503907776, serverAccessCode, player, nil, tpData)
			-- lets try using TeleportAsync, instead of TeleportToPlaceInstance, while still teleporting the player to serverAccessCode
			local tpOptions=Instance.new("TeleportOptions")
			--tpOptions.ReservedServerAccessCode=serverAccessCode
			tpOptions.ServerInstanceId=serverAccessCode
			tpOptions:SetTeleportData(tpData)
			TeleportService:TeleportAsync(17503907776, {player}, tpOptions)
		end)

		if success then
			print("Successfully teleported", player.Name)
		else
			warn("TeleportToPlaceInstance failed:", errorMessage)
		end
		wait(math.random(4,6))
	end

This gets printed:
Screenshot_748

This is what happens:
Screenshot_749

3 Likes

it means that the target place is private or you may have provided the wrong id

3 Likes

How do I join a private reserved server then? I have the access id? Is there no way?

1 Like

This is the script used when someone is making a server:

local placeId = 17503907776
			--local id,serverAccessCode=game:GetService("TeleportService"):ReserveServer(placeId)

			while true do
				-- lets use teleportToPLace instance instead.
		--	local tpData={
			--	ReservedServerCode=
		--	}
			local tpOptions=Instance.new("TeleportOptions")
			--tpOptions:SetTeleportData(tpData)
			tpOptions.ShouldReserveServer=true
			-- lets use teleportAsync to teleport to a private server
			game:GetService("TeleportService"):TeleportAsync(placeId,{plr},tpOptions)
			
				wait(7)
			end

I don’t know much about the TeleportService but I’m 99% sure that you can’t teleport players into private/reserved servers.

2 Likes

But how do people like MiniToon do it (like the build mode in Piggy)?
By the way the first teleport works its just that the second one - where a different user wants to teleport to the same player with the same access code - does not work.

Just checked. Maybe this could help:

1 Like

I think you need to do

TeleportService:TeleportToPrivateServer()

instead of

TeleportService:TeleportAsync()
1 Like

I figured out the solutions. A day of my life wasted :frowning: because of misunderstanding. Its my fault sorry guys for wasting yall’s time.
Basically I shouldn’t have did:

tpOptions.ShouldReserveServer=true

The reason why I did that is because I thought if it was false, when a player would want to make their own server it would teleport them to the same one of the already existing one. This is not the case :smiley:

Again, sorry everybody.

1 Like

Good job on finding the solution! Don’t feel bad about it, though, the devforum is mainly used by people to get help, anyways. You’re not wasting anyones time :smile: Happy scripting!

1 Like

Nvm, it does not work :frowning:
The joining friends thing, pretty sure it works.
But now there is another issue - the servers are not private anymore! So I kept joining some random guy’s server!

If anyone knows how to fix this please help. This is the game: