TeleportData Table's children are nullified!

I’m working on a stage feature of a game I’m working on, and I need to pass the children of a folder to the 2nd place of the game.
Basically when I check for the children in a pairs loop, they’re all nil!
This is the output:
image_2022-10-28_190550034
The numbers are for debugging (it only stops at the first part).

This is the part of the script for the first place where you get teleported:

					game:GetService("TeleportService"):Teleport(PlaceID,v,v:WaitForChild("Values"):WaitForChild("Units")) -- v is a Player btw

This is a server script.
And this is the script for the 2nd place:

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,Units)
	wait(0.1)
	print(Units.Name)
	print(Units.ClassName)
	print(Units:GetChildren())
	print(1)
	for i,v in pairs(Units:GetChildren()) do
		print(2)
		if game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)]
				Unit.Shop.Disabled = true
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)]
				if Unit:FindFirstChild("Shop") then
					print(4.5)
					Unit.Shop.Disabled = true
				end
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)]
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		end
	end
end)

This script is a local script in ReplicatedFirst!

Please help!

you should send encoded table using httpservice:JSONEncode(table) and then decode it

1st place script:

local HTTPService = game:GetService("HTTPService")
local TeleportData = HTTPService:JSONEncode(v:WaitForChild("Values"):WaitForChild("Units")
game:GetService("TeleportService"):Teleport(PlaceID,v,TeleportData)

2nd place script:

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,TeleportData)
local DecodedData = game:GetService("HTTPService"):JSONDecode(TeleportData)
	wait(0.1)
	print(DecodedData.Name)
	print(DecodedData.ClassName)
	print(DecodedData:GetChildren())
	--example end--

Something like this?

2nd place script shoud look like this:

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,TeleportData)
local DecodedData = game:GetService("HTTPService"):JSONDecode(TeleportData["Data"])
wait(0.1)
print(DecodedData.Name)
print(DecodedData.ClassName)
print(DecodedData:GetChildren())

nvm your one is good because this one supposed to be for messagingservice mb

nvm use your own script it should work fine this one is a script for messagingservice

You can’t pass instances in teleport data, datastores, messaging service, or HTTP service.

1 Like

Do you know how I can pass the data in that case?

use table? if you aren’t using it already

You could instead send the data that you got from datastores, to identity the Unit the player has equipped. The other server could identity it just like the first server.

@madonchik123 @avodey
So I think it’s working but I got this error:

could you show what line that is

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,DataTable)
	wait(0.1)
	print(DataTable:GetChildren())
	print(1)

3rd line!

Nevermind.
I had to do a pairs loop!

image

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,DataTable)
	wait(0.1)
	print(1)
	for i,v in pairs(DataTable) do
		print(v)
		print(2)
		if game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)]
				Unit.Shop.Disabled = true
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)]
				if Unit:FindFirstChild("Shop") then
					print(4.5)
					Unit.Shop.Disabled = true
				end
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)] then
			print(3)
			if v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)]
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		end
	end
end)

It only printed one value and stopped at this line:

			if v.Value >= 1 then

EDIT: I did not have the Red cat (I’m doing all of this in a testing place so yeah) but it did not continue to the next one, which I have!
What do I do?

maybe because it tried to get value from a basepart?

try this

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(TeleportGui,DataTable)
	wait(0.1)
	print(1)
	for i,v in pairs(DataTable) do
		print(v)
		print(2)
		if game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)] then
			print(3)
			if v:IsA("NumberValue") and v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[tostring(v)]
				Unit.Shop.Disabled = true
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)] then
			print(3)
			if v:IsA("NumberValue") and v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[tostring(v)]
				if Unit:FindFirstChild("Shop") then
					print(4.5)
					Unit.Shop.Disabled = true
				end
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		elseif game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)] then
			print(3)
			if v:IsA("NumberValue") and v.Value >= 1 then
				print(4)
				local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[tostring(v)]
				Unit.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect
				wait(0.1)
				local OwnedUnit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.UnitSelect:WaitForChild(tostring(Unit))
				if OwnedUnit then
					print(5)
					OwnedUnit.LocalScript.Disabled = false
				end
			else

			end
		end
	end
end)

The folder only has NumberValues tho

I still need help!
Can anyone help me?

There is an open sourced module that converts the table into a variable and from there you could sent it to another script with RemoteEvents/Bindable functions:

1 Like

Tried it out.
So I basically replaced if v.Value >= 1 with a remote event to access the server to check from there.
this is the replacement for that line!

This is the result:
image

Server script:

local True = true
local repr = require(3148021300)
game.ReplicatedStorage.CheckValue.OnServerEvent:Connect(function(Player,v,DataTable)
	print(repr(DataTable))
	print(v)	
	if v:IsA("NumberValue") and v.Value >= 1 then
		print(v.."Is available!")
		game.ReplicatedStorage.CheckValue:FireClient(Player,True)
	else
		game.ReplicatedStorage.CheckValue:FireClient(Player)
	end	
end)