How to Properly Associate Multiple Players with Their Assigned Seats on Teleport?

Hello, I’m working on a system where players are teleported into a private game with assigned seats. The teleport data contains player UserIds and their respective seat names. However, I’m concerned that when multiple players join at the same time, the seat assignments might mix up.

Here’s what I currently have:

  • Each player should sit in their assigned seat after teleporting.
  • The teleport data contains a list of {UserId = seatName} pairs.
  • I’m currently checking plr:GetJoinData().TeleportData, but I’m not sure if each player is only receiving their own seat assignment or if it’s mixed with others.

Here’s my current script:

local Players = game:GetService("Players")
local seatFolder = workspace.Seats

local function playerAdded(plr)
	local teleportData = plr:GetJoinData().TeleportData

	if teleportData and teleportData.seatName then
		print("Seat Name:", teleportData.seatName)

		local character = plr.Character or plr.CharacterAdded:Wait()
		if character then
			local humanoid = character:FindFirstChildOfClass("Humanoid")
			local seat = seatFolder:FindFirstChild(teleportData.seatName)

			if seat and seat:IsA("Seat") and humanoid then
				task.wait(1)
				seat:Sit(humanoid)
			else
				warn("Invalid seat or humanoid missing for:", plr.Name)
			end
		else
			warn("No character found for player:", plr.Name)
		end
	else
		warn("No seat data for player:", plr.Name)
	end
end

Players.PlayerAdded:Connect(playerAdded)

My Questions:

  1. Does plr:GetJoinData().TeleportData only contain the teleport data for that specific player, or does it include other players’ data too?
  2. If multiple players join at the same time, could seat assignments get mixed up?
  3. What’s the best way to ensure that each player only receives and processes their own seat assignment?

Any guidance or corrections would be really helpful! Thanks in advance.

From what I understand, teleportOptions:SetTeleportData() is delivered to each player included in the table, so I can give you two ideas on how you could handle it:


1. Use a table with all players

Associate each player’s UserId with their corresponding seat:

local teleportOptions = Instance.new("TeleportOptions")
local seatAsociateToPlayerTable = {}

for i, plr in playersList do
    seatAsociateToPlayerTable[plr.UserId] = "determinatedSeat" -- Assign the seat here
end

teleportOptions:SetTeleportData(seatAsociateToPlayerTable)

TeleportService:TeleportAsync(placeId, playersList, teleportOptions)

On the destination server:

local function playerAdded(plr)
    local teleportData = plr:GetJoinData().TeleportData
    local playerSeat = teleportData[plr.UserId]  -- Use plr.UserId to get the seat

    if playerSeat then
        print(plr.Name .. " has been assigned to seat: " .. playerSeat)
    else
        warn("No seat data found for: " .. plr.Name)
    end
end

Players.PlayerAdded:Connect(playerAdded)

2. Teleport each player individually

Teleport each player separately with their own data:

for _, player in playersList do
    local teleportOptions = Instance.new("TeleportOptions")
    teleportOptions:SetTeleportData({
        seatName = assignedSeats[player.UserId]  -- Assign the seat here
    })

    TeleportService:TeleportAsync(placeId, {player}, teleportOptions)
end

On the destination server:

local teleportData = plr:GetJoinData().TeleportData
local seatName = teleportData.seatName

if seatName then
    print(plr.Name .. " has been assigned to seat: " .. seatName)
else
    warn("No seat found for: " .. plr.Name)
end

yeah i did that

lobby server :

local function teleport(fullyRegistered)
	local playerTable = {} -- List of players to teleport
	local teleportData = {} -- Dictionary to store seat data

	for userId, data in pairs(fullyRegistered) do
		local player = game.Players:GetPlayerByUserId(userId)
		if player then
			table.insert(playerTable, player) -- Add player to teleport list

			-- Check the player's seat
			local char = player.Character
			if char then
				local humanoid = char:FindFirstChild("Humanoid")
				if humanoid and humanoid.SeatPart then
					-- Store seat assignment using player's UserId as key
					teleportData[userId] = {
						seatName = humanoid.SeatPart.Name,
						registrationNumber = data.registrationNumber
					}
				end
			end
		end
	end

	print("Teleport Data:", teleportData) -- Debugging

	local options = Instance.new("TeleportOptions")
	options:SetTeleportData(teleportData) -- Store player seat data

	if #playerTable > 0 then
		teleportService:TeleportAsync(128122330564874, playerTable, options)
	else
		warn("No players to teleport!")
	end
end

reserver server:

local Players = game:GetService("Players")
local seatFolder = workspace.Seats

local function playerAdded(plr)
	local teleportData = plr:GetJoinData().TeleportData
	local playerData = teleportData[plr.UserId] -- Fetch player's specific data

	if playerData then
		local seatName = playerData.seatName
		print(plr.Name .. " has been assigned to seat: " .. seatName)

		local character = plr.Character or plr.CharacterAdded:Wait()
		if character then
			local humanoid = character:FindFirstChildOfClass("Humanoid")

			-- Find the seat and make the player sit
			local seat = seatFolder:FindFirstChild(seatName)
			if seat and seat:IsA("Seat") and humanoid then
				task.wait(1) -- Small delay to let player load in
				seat:Sit(humanoid)
			end
		else
			warn("No character found for:", plr.Name)
		end
	else
		warn("No seat data found for:", plr.Name)
	end
end

Players.PlayerAdded:Connect(playerAdded)

it said No seat data found for in the console

Hi, I would recommend not creating duplicate topics on the same exact problem. This is known as spam and can lead to moderator action. Please use your old previous topic.

yea, i tend to do it, to compare answers, but if its consider a spam then ill stop it :smiley:

Yes, it’s best to just ask the question on the original topic again as it would bump the topic to the top allowing new users to see it.

Also, have you checked out my reply in the original topic?

This one: