Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 19 Jan 2015 06:23 PM |
How do I do this?
I'm having a little trouble with this. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 19 Jan 2015 06:27 PM |
local players = {}
game.Players.PlayerAdded:connect(function(player) table.insert(players, player) end)
game.Players.PlayerAdded:connect(function(player) for i, p in pairs(players) do if p == player then table.remove(players, i) break end end end) |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 19 Jan 2015 06:37 PM |
I'm not sure if I fully understand that script... How is that detecting if the player left the game? |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 19 Jan 2015 06:38 PM |
Oops, I meant to post:
game.Players.PlayerRemoving:connect(function(player) for i, p in pairs(players) do if p == player then table.remove(players, i) break end end end)
So that way when the player leaves, it will remove him from the table. |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 19 Jan 2015 06:38 PM |
Seranok made a mistake. The second connection should be PlayerRemoving. http://wiki.roblox.com/index.php?title=API:Class/Players/PlayerRemoving |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 19 Jan 2015 06:39 PM |
| Ohhhhh, that makes alot more sense. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 19 Jan 2015 06:42 PM |
| Is there any reason not to use game.Players:GetPlayers()? |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 19 Jan 2015 06:44 PM |
| Seranok how do you tab your code on here? O: |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 19 Jan 2015 06:44 PM |
If you're maintaining a list of players, then you should just call game.Players:GetPlayers() like lordrambo said. But if you are doing something fancy like:
local players = { { player = [Reference to player object], points = 5 } }
Then obviously :GetPlayers() will not suffice. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 19 Jan 2015 06:46 PM |
| Hold down `Alt` and then press 0, 1, 6, and 0 on the number pad. This will create a space character. Copy and paste this space character. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 19 Jan 2015 06:52 PM |
function test() print'test'; end
test''
O::::: |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2015 06:54 PM |
test=''function yo() print(test); end;
yo(); |
|
|
| Report Abuse |
|
|