Is there a way to send data between two places during teleporting?

I’m currently working on a rhythm game, though, it’s a bit more complex than other ones, so I made a tutorial for it in another separate game. Between songs loading, I have a splash screen with the thumbnail of the song, the name of the song, who mapped it, etc. The only problem is, I’m not sure how to change the screen depending on the song data, and If I make a splash screen for every song there is, it’ll cause a lot of unnecessary lag.

My main question is if there is a way to send data between two places, so the main ‘Lobby’ sends the song data to the ‘Tutorial’ place.

I’m using a custom loading screen teleport, but I don’t think I can send data using this…

(Let me know if I left something out, or you need more details)

4 Likes

I am pretty sure you can do what’s in this page:
TeleportToPrivateServer
You can add arguments to the reversed server.

1 Like

When you use :Teleport() function, it has 2 required arguments and 2 optional arguments.
They are: teleportData and customLoadingScreen, just add some data table to the third argument which is teleportData, and access it from the other place using :GetLocalPlayerTeleportData().
Read about it more in this article.

4 Likes

There’s a note on the teleport data in the API

As the teleportData is transmitted by the client it is not secure. For this reason it should only be used for local settings and not sensitive items (such as the users’ score or in-game currency).

2 Likes

So if I were to do

local songData = {
     'Tutorial'
     'ID OF IMAGE'
     'Artist Name'
     'Mappers Name'
}

then send that with

TeleportService:Teleport(placeID,Player, nil, loadingScreen, songData)

It would work?

2 Likes

You mixed the arguments kind of, but it should be in this form:

TeleportService:Teleport(placeID,Player, songData, loadingScreen)

And like this it should work.

1 Like

Ohhhh, ok, but i’m still confused on what @Badandy11 said about

As the teleportData is transmitted by the client it is not secure. For this reason it should only be used for local settings and not sensitive items (such as the users’ score or in-game currency).

I don’t think it would effect me, because it’s not something like currency or in-game items, it’s just song data…

And if I did switch it to not do this, what would I do then?

2 Likes

Just send the data table with all the data you need to send, and in the tutorial game, just do in a LocalScript:

local dataTable = TeleportService:GetLocalPlayerTeleportData() -- All the data you sent from the other game.

return dataTable[3]

Etc.

1 Like

Doing a print() test real quick…

2 Likes

Make sure you were teleported and you sent all the data to the other place and it should work perfectly.

I’m pretty sure TeleportService:Teleport(otherPlaceId, player, nil, songData, loadingScreen)

should have songData and loadingScreen switched

1 Like

He said songData has to be the third argument.

1 Like

You put too many arguments in there. It has only 4 arguments, make sure the form of the arguments is:

:Teleport(plcaeId, player, teleportData, loadingScreen)
1 Like

Oh… My bad! Works great now :slight_smile:

1 Like