so I’m trying to pass data through 2 places with a table with tables inside it, and I need to detect if the table’s linked unit (It’s a ui object) is inside one of the specified locations. However, the first object cannot be detected in the first location, so it should be checking the different locations with elseif. And that is where the problem comes. The loop just *ends when it’s not found in the first location. And a proof that it’s the elseif that doesn’t work is that it should print something when it’s detected!
Here’s the script:
game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:Connect(function()
local DataTable = game:GetService("TeleportService"):GetLocalPlayerTeleportData()
wait(0.1)
print(1)
for i,v in pairs(DataTable) do
print(DataTable.RedCat.UName)
print(2)
if game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[v.UName] then --first location
print(3)
if v.UValue >= 1 then
print(4)
local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").BuyCats.UnitSelect[v.UName]
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[v.UName] then --second location
print(3)
if v.UValue >= 1 then
print(4)
local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").YourCats.Storage[v.UName]
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[v.UName] then --third location
print(3)
if v.UValue >= 1 then
print(4)
local Unit = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").UnitGacha.Storage[v.UName]
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)
All of the locations are correct! I used the same script in the main place as well and it works (the 2nd place has the same UI objects)!
EDIT: I get an error when I test it: ObjectName is not a valid member of First Location! And there are no spelling errors; again, it works in the main place!
Anything helps!