Attempt to index nil with (Teleport data)

If this is really what you are using… I don’t know how you can stand having a global variable that isn’t defined and also why is it like that just use the script like this bro


local teleportservice = game:GetService("TeleportService")
local replicatedstorage = game.ReplicatedStorage
local escapeguione = replicatedstorage:WaitForChild("EscapeGuiOne")

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local humanoid = hit.Parent.Humanoid
		local colony = hit.Parent.Colony
		local arrayofplayers = {
			
		}

        local teleportdata = {
	             
		}
		for i, v in pairs(game.Players:GetPlayers()) do
			if v.Character:WaitForChild("Colony").Value == colony.Value and colony.Value ~= "" then
				if game.ReplicatedStorage.ColonyStuff:FindFirstChild(colony.Value).MemberPermsFolder.MembersCanExit.Value == true or game.ReplicatedStorage.ColonyStuff:FindFirstChild(colony.Value).ColonyLeaderValue.Value == humanoid.Parent.Name then
				table.insert(arrayofplayers, v)
				
					teleportdata[v.Name] = {v.Name}
					for i, v in pairs(teleportdata) do
						print(v)
					end
					
					table.insert(teleportdata[v.Name], "VColonyValue")
					teleportdata[v.Name].VColonyValue = v.Character.Colony.Value
					print(teleportdata[v.Name].VColonyValue)
					
					for i, v in pairs(teleportdata) do
						print(v)
						--for e, t in pairs(teleportdata[v.Name]) do
							--print(t)
						--end
					end
				
				end
			elseif v.Character.Name == hit.Parent.Name then
				teleportservice:Teleport(98985454249054, game.Players:GetPlayerFromCharacter(hit.Parent))
				print("teleported one player not in a colony")
			end
		end
		
		local teleportoptions = Instance.new("TeleportOptions")
		teleportoptions:SetTeleportData(teleportdata)
		teleportservice:TeleportAsync(98985454249054, arrayofplayers, teleportoptions)
		
	end
end)
1 Like

i dont need help on that rn bruh

dude u dont put teleport data inside the for loop u define it at the top it wasnt just the global variable i was showing you dang bruh you really hardheaded

it doesnt change anything if i change the variable name

Where have you put the small code i sent?

1 Like

if you talking about this

for i, v in pairs(TeleportData) do
print(i,v)
end

i put it under the teleportdata variable

You mean “TeleportData”, right?

u aint even really help me on this bruh like i appreciate the help but u barely did nothin

1 Like

yes i do mean TeleportData

local TeleportData = joinData.TeleportData

This prints to nil? What about joinData ?

joinData prints to the “table: 0x” thing whenever i teleport

1 Like

replace TeleportData with joinData and see what it says

That’s a good sign. I think your table is only nil when it’s not with the join data

wdym by that, do i just change the variable names or something else? doesnt really make sense to me

1 Like

for i, v in pairs(joinData) do
print(i,v)
end

Screenshot 2025-03-02 012021
i get these

Now in pairs(joinData.TeleportData) do

Screenshot 2025-03-02 012619

mmmh, alr, now try w joinData.TeleportData[player.Name]

Screenshot 2025-03-02 012907