I have a script that makes it so that when you are teleported to that place in the game, it will check if your in a certain colony. Each time i test it, it says “Attempt to index nil with SubLimitless” (SubLimitless is my userame)
In the script that gives the data, it prints lua teleportdata[v.Name].VColonyValue the correct way without any errors, unlike the 2nd script (the one below that fires when you join the other place which i was talking about before)
Code for 2nd script (error):
game.Players.PlayerAdded:Connect(function(player)
task.wait(3)
local joindata = player:GetJoinData()
local teleportdata = joindata.teleportdata
local colonyvalue = teleportdata[player.Name].VColonyValue
end)
I entered the game in studio when it showed the {}, meaning i wasnt in the starter place before that, meaning there was no teleport data because i didnt teleport
I am inputting data though, this is the teleporter script that teleports me to the 2nd place where i got the original error from
lines 26, 27, 28, 44, 45 and 46 show me putting data
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 = {
}
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 = {
}
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)
erm just an observation I don’t see any line 7 from either script that could return the error you showed in the picture. It would help to see where that line 7 error is coming from since that’s the whole reason for this post
also by the way, I updated the script and put TeleportData instead of teleportdata (used tutorial) and it seemed to remove the error but the value is still nil
Wait, when you said you changed the name to TeleportData, were you speaking about the variable name or :GetJoinData().TeleportData ? Whatsoever, make sure you wrote :GetJoinData().TeleportData, not teleportdata