Sending teleportData to reserveServer

i guess, there is still some question… i sue JSONencode and also :

for userId, data in pairs(teleportData) do
        print("UserID:", userId, "Seat Name:", data.seatName, "Registration Number:", data.registrationNumber)
    end

which apparent work, but i dont how to extract it.

it printed what i said before

Yes because now the data is decoded. You can now use the data as you want. You can’t print it but you can now properly use it.

can you kindly show how to use it, it always print

table : nil

maybe i use wrongly? i pretty i dont even know to extract it

Wait,

You said this worked correct? And printed what you wanted right?

If so, then what’s the issue here? You can just retrieve the data by doing:
teleportData[player.UserId] and handling it how ever you want it.

but it printed nil, like im sooo confuse, maybe hours of in front of my pc starting to get to me

maybe the user ID might be stored as a string instead of a number, idk

Umm… This is getting confusing. Please give me a discrete response. Did it work or not? What does teleportData print? Does it print {“123456”:{“seatName”:“SeatA”,“registrationNumber”:42}}? If it does then do this:

local HttpService = game:GetService("HttpService")
for userId, data in pairs(HttpService:JSONDecode(teleportData)) do
        print("UserID:", userId, "Seat Name:", data.seatName, "Registration Number:", data.registrationNumber)
    end

can you try this and send me a screenshot of output? It’s just that all these contradicting explanations have confused me.

local function playerAdded(player: Player)
    local data = player:GetJoinData()
    local tpData = data.TeleportData and data.TeleportData[player.UserId]

    for k, v in tpData do print(k, v) end
end

First of all, teleport data can be used only on client, to send data between reserved servers you need to use memory stores

Also, if you use console, tables are only displayed as references, you need to use output in studio to see table’s content, try to loop through the table and see if it have elements you’ve sent

actually it works now…

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

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

	for userId, data in pairs(teleportData) do
		print("Seat Name:", data.seatName)

		-- Get the player from their UserId
		local player = Players:GetPlayerByUserId(userId)
		if player then
			print("Player Found:", player.Name)

			-- Get the player's character
			local character = player.Character or player.CharacterAdded:Wait()
			if character then
				local humanoid = character:FindFirstChildOfClass("Humanoid")

				-- Find the seat and make the player sit
				local seat = seatFolder:FindFirstChild(data.seatName)
				if seat and seat:IsA("Seat") and humanoid then
					task.wait(1) -- Small delay to let player load in
					seat:Sit(humanoid) -- Auto sit the player in their seat
				end
			else
				warn("no char")
			end
		else
			warn("Player not found for UserId:", userId)
		end
	end
end

Players.PlayerAdded:Connect(playerAdded)

but my question now is :

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