Cannot figure out at all how to teleport to a specific spawn while teleporting to place

What I am trying to make happen: I want to teleport the player to a specific spawn when they teleport to another place within the game. Thats it.

Annoyingly what keeps happening is that I can get the player to teleport to the place correctly, but they never teleport to the spawn I want them to, and they instead spawn at 0, 0, 0.

I’ve tried looking how TeleportToSpawnByName AND TeleportASync works, read through all of the usage for it, read through forum posts, watched tutorials, but nothing has fixed it at all.

My current code is this:

local TeleportService = game:GetService("TeleportService")
local PlaceID = 118068710022105
local spawnName = "SpawnLocationA"
local partToTouch = script.Parent
partToTouch.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		TeleportService:TeleportToSpawnByName(PlaceID, spawnName, player)
	end
end)

I’m a relatively beginner scripter and I’m simply trying my best. :sad:

I’m only posting here because I am completely out of options. Any help would be GREATLY appreciated! :sad:

1 Like

Not 100% sure on how spawns works honestly but you can always just “force spawn” them by moving their character to the desired location? for example using MoveTo() to decide where the player got to be at ?

1 Like

Unfortunately what I’m trying to do involves multiple spawns which depend on what other place you came from, for example coming from Place A to Place Z brings you to Spawn A in Place Z, but coming from Place B to Place Z brings you to Spawn B in Place Z.

1 Like

If you are using universal places you can send info between servers. Using roblox db you can know from which spawn to go based on that ?

Documentation says no other Teleport method should be used apart from TeleportAsync (its combination of all). But at the same time it does not provide or mention spawn location in TeleportAsync or the TeleportOptions, so my guess is that you have to send SpawnName as TeleportData and when player joins all you do is check the data by doing Player:GetJoinData().TeleportData.SpawnName and teleporting it to there

1 Like

It worked perfectly! Thank you so much for the help.

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