Yeah, so when you do this,
you’re setting the teleport data to
{
{
Player1UserID,
Player2UserID,
Player3UserID
{
}
So simply getting the length of the teleport data wouldn’t work - you would need to get the length of teleportData[1]. Also, it is recommended that you set teleport data to a dictionary.
You can think of dictionaries as tables, but with keys. So dictionaries are just a list of key, value pairs. What I mean by this is that each value has a specific key assigned to it. For example
-- Edit: changed "Apple" to "Mango"
-- Table
local table1 = {
"Mango",
"Sword",
67
}
-- Dictionary
local dictionary1 = {
Fruit = "Mango",
Weapon = "Sword",
Money = 67
}
In tables, the keys are just the indexes so in the above example, table1[1] would return "Mango", but dictionary1[1] would return nil. To access the “Mango” value, you would have to do dictionary1["Fruit"] or dictionary1.Fruit. The nice thing about dictionaries is that you don’t have to know the order of the values - you just have to know which key corresponds to which value, making it really clean to use. However, unlike tables, you cannot use the # operator to get the length of a dictionary. You must manually count it through a loop.
So, using a dictionary for the teleport data, we could just do
teleportOptions:SetTeleportData({TotalPlayers = #players})
This way, when retrieving the teleport data, you would simply do
teleportData.TotalPlayers
Edit 2: The name dictionary is a little self-explanatory. You have a key (the word), and then you have the value that corresponds to the key (the definition).