Hi,
I do
playersInZone[player.UserId] = true
But when I print
print(playersInZone[1])
it prints nil.
But if I print
print(playersInZone[player.UserId])
I then get { [id] = true }
What am I doing wrong?
Hi,
I do
playersInZone[player.UserId] = true
But when I print
print(playersInZone[1])
it prints nil.
But if I print
print(playersInZone[player.UserId])
I then get { [id] = true }
What am I doing wrong?
In your first line, playersInZone[player.UserId] = true
, you’re not using an array, but rather a dictionary. This is where you have a key, which is the userId in this case, and it corresponds to a value, which is also true. If you want to use it as an array, you can do as follows:
table.insert(playersInZone, player.UserId)
this way, when you print playersInZone[1]
, it’ll return the players userID.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.