I was messing around with the Player:GetJoinData() and LaunchData to understand how it works, so I wanted to make a simple system of creating a Reserved Server when the LaunchData is equal to “privateRoom”, in theory, according with the documentation “Only available on the first join. If the user teleports to another server, the data isn’t included”, but this seems not to work. When the player is teleported to the reserved server, the launchData still appears causing an “infinite” teleportation problem.
Here’s the code:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local function reserveAndTeleport(plr)
local serverCode = TeleportService:ReserveServer(game.PlaceId)
TeleportService:TeleportToPrivateServer(game.PlaceId, serverCode, { plr })
end
local function onPlayerAdded(player)
local launchData = player:GetJoinData().LaunchData
print(player:GetJoinData())
print(launchData)
if launchData then
if launchData == "privateRoom" then
print("Private server detected... Teleporting Soon.")
task.wait(10)
reserveAndTeleport(player)
else
print("LaunchData not recognizable")
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)