How should I send and receive data (Teleport Service)

How should I send and receive data via private server teleport? (Teleport Service)

You can use TeleportOptions and use the :SetTeleportData/:GetTeleportData methods.

That’s what I’m doing, but I’m getting nil.

Are you using teleportasync to send the teleportoptions?

No, i using TeleportService:TeleportToPrivateServer()

if you’re interested :

						local code = TeleportService:ReserveServer(PlaceId)
						
						local option = Instance.new('TeleportOptions')
						option:SetTeleportData({
							['Map'] = Choosed
						})
						
						TeleportService:TeleportToPrivateServer(PlaceId, code, playerQueue, 'SpawnLocation', option)

and secound :

	local option = Instance.new('TeleportOptions', workspace)
	option:GetTeleportData()

        print(option.Map) --> getting an error (nil)
--send snip
local ts = game:GetService("TeleportService")
local inv = player.Backpack:GetChildren()
ts:Teleport(123456789, player, inv) --what you're sending

--receive snip
local ts = game:GetService("TeleportService")
local td = ts:GetLocalPlayerTeleportData() --what you sent

If I remember correctly only TeleportAsnyc sends teleport data,


Ok yes it is needed that you use it.
Edit ok and maybe also TeleportToPrivateServer.
But Teleport not sending data still stands!!!

For the record, Teleport doesnt allow you to send data, you must use TeleportAsync as shown by my reply but just thought I’d make sure that you know in case you ever need it in the future!

Ok just played around with the privateserver teleporting and it seems that the fourth parameter is a variant meaning it can be any type and you can’t use “teleportoptions” for it.

local code = TeleportService:ReserveServer(PlaceId)
						
						local data = {
							['Map'] = Choosed
						})
						
						TeleportService:TeleportToPrivateServer(PlaceId, code, playerQueue, 'SpawnLocation', data)
-- Local script in replicatedfirst

local TeleportService = game:GetService("TeleportService")

local teleportData = TeleportService:GetLocalPlayerTeleportData()

print("Local player arrived with this data:", teleportData)

I find MemoryStoreService to be more reliable when it comes to short-term data transfer/storage, it’s basically like datastores but it updates globally and reads/writes a lot faster.

I’ve tried all the ways. and it doesn’t work.

What I’m doing is sending a table. There is a mirror set up on the other side that just reloads the backpack. Works fine. Maybe I misunderstood the question.

From the look of thing Teleport() cant send data, at least from my reading of the documents and many posts I’ve seen today that is the case

GameA
GameB

Use the portal in front of where you spawn from A to B.
You can edit them also. I’m sure this is just one way to send “data”.

This is sending a table of your backpack over to be read and set back up in gameB.

Um what is this? I dont feel like playing games rn lol :3

It’s a test program you can edit to see how it works.

Ok um whats the point of the place? Does Teleport() work with sending data? Is that what you are trying to tell me?

Yes, it teleports and sends data. Maybe we are talking about two different types of data here. Probably should go to PMs at this point if you still have questions.

I think this is more what you may have been looking for …

--script 1 send
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local placeId = 123456789
local player = Players.LocalPlayer
local teleportData = {message = "My Message"}

TeleportService:TeleportAsync(placeId, {player}, nil, teleportData)

--script 2 receive 
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local teleportData = TeleportService:GetLocalPlayerTeleportData()
    if teleportData then
        print(teleportData.message)
    end
end)