Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to create a table for a specific player without doing the following?

Asked by 8 years ago
local Table1 = { }

game.Players.PlayerAdded:connect(function(player)
Table1[player] = { }
end)

or

--In ModuleScript

local Table1 = { }



return Table1

The reason I ask this is because the for loop I'm using doesn't recognize the tables in both of those ways, I can't think of a different way to create a table specifically for the player, without using their ID which doesn't work:

local player.userId = { }  --Expected identifier got, '.'

If it is possible how so?

0
Make a different table for each player in the table itself. legosweat 334 — 8y
0
Also consider using datastores. GoldenPhysics 474 — 8y
0
Is that not what I have in option 1, a table for each player in a table? Also, I don't really want to use datastore because it's only a temporary thing, I'm OK with it being deleted after the player leaves. Evadable 65 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

By what it sounds like you're trying to do, no, there's not.

The issue with tables is of course that they are just value holders. You'd have to give extra context to fully understand what you wanted to get from it of course, but you also need to consider why your loop doesn't recognise them.

Perhaps you should try using pairs() to iterate through tables?

0
I did use ipairs(), it just does not seem to think the table holds anything, I will find another way to do what I want, thank you. Evadable 65 — 8y
0
Use pairs(); never use ipairs, as it is slower than any other practical alternative. User#6546 35 — 8y
Ad

Answer this question