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:
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)
local HTTPService = game:GetService("HTTPService")
local TeleportData = HTTPService:JSONEncode(v:WaitForChild("Values"):WaitForChild("Units")
game:GetService("TeleportService"):Teleport(PlaceID,v,TeleportData)
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.
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?
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)
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:
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!
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)