Teleport data not working

The data returns as nil.

Script when joined the game:

local code

		-- lets get the code (reservedServer) that we're in
		local success, err = pcall(function()
			code=game:GetService("TeleportService"):GetLocalPlayerTeleportData()
		end)
		if success then
			print(code) -- this prints out nil, why Idk
		else
			print(err)
		end

and this is the script I use to send players:

local reservedServer=game:GetService("TeleportService"):ReserveServer(17503907776)
			local teleportData = {
				ReservedServerCode = reservedServer
			}
			while plr do
				game:GetService("TeleportService"):TeleportToPrivateServer(17503907776,reservedServer,{plr},teleportData)
				task.wait(math.random(2,7))
			end
2 Likes

Both of the scripts are server sided.

local placeId = 17503907776
			local reservedServer = game:GetService("TeleportService"):ReserveServer(placeId)
			local teleportData = {
				ReservedServerCode = reservedServer
			}
			while true do
				game:GetService("TeleportService"):TeleportToPrivateServer(placeId, reservedServer, {plr}, teleportData)
				wait(7)
			end
plr.Chatted:Connect(function(msg)
		if msg == ":code" then
			local success, err = pcall(function()
				local data = game:GetService("TeleportService"):GetLocalPlayerTeleportData(plr)
				if data then
					print("Local Player Teleport Data:", data)
					for key, value in pairs(data) do
						print(key, value)
						if type(value) == "table" then
							for subKey, subValue in pairs(value) do
								print("  ", subKey, subValue)
							end
						end
					end

					if data.ReservedServerCode then
						print("ReservedServerCode found:", data.ReservedServerCode)
					else
						print("ReservedServerCode not found in teleport data")
					end
				else
					print("No teleport data found for player")
				end
			end)

			if not success then
				print("Error retrieving teleport data: " .. err)
			end
	end
	end)

Why does it not work! It printed there is no teleport data!

1 Like

Yo guys just fixed it I forgot to put nil before teleport data lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.