TeleportService | TeleportData = nil?

I just started working with TeleportService since I need to teleport players to an other place after they used an elevator in the starter place, and I want to send some data with the players from the elevator so that I can kick all the players that try to join the place as well from their profiles. I have tried to find a solution from other dev forum posts, and the roblox create page as well, but I still couldn’t fix it. Here is my code.

--code from the starter place from a module script--
function GameManager.StartGame(GameData)
	local self = setmetatable(GameData, GameManager)
	local TeamStats = CreateStats()
	local SpawnPointUsed = {}
	
	
	
	local TeleportOptions = Instance.new("TeleportOptions")
	local teleportData = {}
	teleportData["AcessPass"] = true
	teleportData["Team"] = GameData["Team"]
	TeleportOptions.ShouldReserveServer = true
	TeleportOptions:SetTeleportData(teleportData)
	Teleportation:TeleportPartyAsync(PlaceId, GameData["Team"], TeleportOptions)
	
--code from the other place in a server script
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

print("something")
Players.PlayerAdded:Connect(function(Player)
	local JoinData = Player:GetJoinData()
	local teleportdata= JoinData.TeleportData
	print(teleportdata["AcessPass"])
	
end)

TeleportService:GetLocalPlayerTeleportData() is a function which gives all the data that is being send to the client. You might want to use that. (Can only be called on the client)

1 Like

I can give it a try, even though that also seemed to not work earlier, I have read this post abt what I did above your message Teleporting Between Places | Documentation - Roblox Creator Hub, shouldn’t that just work as well?

In the link you provided there’s a warning that states:

Which means that you must use the Roblox Player to test TeleportService functionalty instead of Studio which could explain why you’re receiving nil

I think he does playtest it on the application, since the comments already say that its other places

Which comment are you quoting though?

its at the top of his second script
edit: bru i dont find the quote anymore

Oh lol I thought you meant comments on the DevForum. In my interpretation though, that doesn’t really confirm where they’re testing as they could still be using Studio to do so

I am testing it on the website, not in roblox studio.

I did some research on TeleportService and this is what I found: You want to teleport a group of players to a different place when they use an elevator and send data with them as well. You’re using TeleportService:TeleportPartyAsync to do so, but the parameters you’re inserting to the function aren’t what TeleportPartyAsync expects which are:

  1. The place id of the place you wish to teleport the players to
  2. An array containing every Player Instance you wish to teleport
  3. Either a string, number, bool value or a table that does not contain mixed keys (example below) you wish to send as data. You’re sending a TeleportOptions Instance instead which is incorrect for the TeleportPartyAsync function which is probably why you’re receiving nil
  4. A custom loading screen you wish to send (optional)

Mixed key table example (essentially a table that’s both an array and a dictionary):

local table = {"Hello!", Value = 234, ["Color"] = "Red", 567, [5] = true}

I kind of need to send multiple ppl to one specific server, and I want to send data with them so that I can kick others that try to join their game from their profile, so what would you recommend me to use then?

The issue isn’t necessarily the function you’re using, but you’re not inputting correct data to the function in parameter 3. You’re using a TeleportOptions when parameter 3 wants either a string, number, boolean or non-mixed table as I explained in my comment

Ah I see, I can prob fix that then, but can I still pass teleportoptions then with teleportpartyasync, or no?
Since I do need that to be passed as well.

If so then you need to use TeleportAsync instead of TeleportPartyAsync

Hm alright, so I probably have to use a loop or something to send all the players to the server then or something like that, eh I will check it out soon, and if I run into any problems I will come back to this post.
Thank you that you are taking your time to help me out with this:))

TeleportAsync is different than Teleport, it accepts multiple players so there’s no need to use a loop. Here’s how to use it:

TeleportService:TeleportAsync(
	12345, -- This is the place id
	{player1, player2, player3}, -- An array containing players you want to teleport
	teleportOptions -- The teleport options Instance you want to send
)

oooooh okay, and with teleport async I can send a fourth argument that is the table with the data that I want to pass as well?

Be careful because TeleportAsync doesn’t have a 4th argument. If you follow my example it shows you what the function needs and I also recommend you read the docs for more info on how to use the function here

Huh I swear I have read that I could pass data with teleportservice as well

Well TeleportService is an Instance (and a service) so you can’t pass data using it directly but it does have multiple functions you can use to do so. I read the document to learn about it too and from what I understood a lot of the functions (methods) seem to do the same thing so I understand the confusion. TeleportAsync seems to be the one you need which is why I recommended it