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

How would I add a player's name to a table?

Basically, for my place, there are a set of command that high ranks in a certain group can use. However, I want to be able to let others have access to these commands by giving them commands in game. The best idea I came up with to do this is to create an empty table and add people's names to the table while I'm in game, so that whenever they speak a certain command, the script registers it. I already got the iteration part done; all I need to know is how to player names to a table. Could someone tell me how I could do this? Thanks.

1 answer

✓ Accepted answer

It's very easy. Lua provides a built in function to add values to tables called table.insert(). It's pretty self explanatory.

table.insert(tableName, value)

This will place value at the end of the table, but there's also an optional argument that dictates where the value is added.

table.insert(tableName, 2, value) --Puts it at table[2].

1 comment

0

Thanks!

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