|
| 11 Aug 2012 05:27 PM |
I need to be able to add them, which I can do, but also remove them when I need to. Them being users in the game.
table.remove() only takes which number it is in the table..... all I have to reference the user is their name. >.< |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 05:32 PM |
table = {["Player"] = true} table[player.Name] = true
Set a player name value to true when their in the table
and then
table[player.Name] = false
when you want to remove it |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 11 Aug 2012 08:34 PM |
... Brofession's idea looks like it would work (though I'd use nil, not false) and you just totally ignored it. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 11 Aug 2012 08:37 PM |
local PlayersList = {}
PlayersList[game.Players.Player1] = true -- This one line will add the player to the table.
for Player, _ in pairs(PlayersList) do print(Player.Name) end
--> Player1
PlayersList[game.Players.Player1] = nil
for Player, _ in pairs(PlayersList) do print(Player.Name) end
--> (Nothing prints)
So basically, use the player object itself as the index, and then just set the value to true, or nil.
|
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 08:43 PM |
| @Droid I didn't ignore it, I was seeking another method. |
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 11 Aug 2012 08:47 PM |
| The easiest and most efficient method is the earlier mentioned method. Although there can be other methods, they would require a lot more scripting, and take longer to run. |
|
|
| Report Abuse |
|
|