How to get configuration when a 'party' of players teleport?


I am currently making a dungeon game and of course it allows options to choose from and players can base a dungeon by name, difficulty, hardcore, etc. I have the ‘making’ of all of that happening down but, I am not sure how to ‘get’ that configuration to let the server know after they teleport to handle out a dungeon based on the config the party chose before they teleported. Also, the config would be completely based on the parties Lobbyleader since thats the person who made and configured the dungeon.

Tl;DR, I am not sure how I can get configuration/data to let the server know what to do after a party or a group of players teleports to a dungeon and handle it based on that.

1 Like

You can use TeleportData to transfer a configuration data table across the teleport. TeleportData is also superior to other methods of transferring data over teleports, because it can be handled on the server, eliminating the risk of someone modifying the client and make messing with the data.

Hope this helps you out!

TeleportService has a very good thing called “GetLocalPlayerTeleportData”, it allows you to send and receive your data over teleports and is much easier than other common methods, as this method handles it on the server which is much safer, especially if the data you are transferring is crucial to gameplay, as client data manipulation could occur if not in the server, seriously affecting gameplay.

You will need to pass the data in the teleport and then retrive it using “GetLocalPlayerTeleportData”!

Here’s a little example:

-- This will be on the 1st Server (before teleport!)
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

local Player = Players.LocalPlayer
local Data = {
    PlaceId = game.PlaceId,
    Dungeon = "Spooky Dungeon"
TeleportService:Teleport(PlaceId , Player, Data)

Great, now we’ve teleported the player and the data we need to get them going once they are in the desired server, but how do we get it?

-- This is on the 2nd Server (the server you teleported to!)
local TeleportService = game:GetService("TeleportService")

local Data = TeleportService:GetLocalPlayerTeleportData()
if Data then
    local PlaceId = Data.PlaceId
    local Dungeon = Data.Dungeon 

So as you can see, we passed a string of the name of a dungeon and the ID of the original game they came from, however you can remove this should you not want it, you can also add other values if you want too! Let me know if you have any issues and I’ll be glad to help.

A couple things to note are that this service does not work during playtesting in Roblox Studio! So remember to test on the published version of the game on the actual application!

You can read more about the TeleportService and GetLocalPlayerTeleportData here if you want some more detailed documentation about the service as a whole.

Good luck! :smile: