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
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?