Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why when i am setting the index for a table does it not use the reference "player"?

Hi. i want my script to add the players name to a table as an index and have its value set to a boolean but when i use "player" parameter from the player added event the tables index gets set to ["player"] instead of the actual players name.

when i print out the index player it prints "player" instead of the players name

local Table = {}
game.Player.PlayerAdded:Connect(function(player)
	Table.player = true
end)

1 answer

✓ Accepted answer

Hello, Code1400!

Your code wasn't interpreting player as a variable, so the script wasn't using it's value, here's a fixed script:

local Table = {}
game.Player.PlayerAdded:Connect(function(player)
    Table[player] = true -- this interprets 'player' as a variable
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.