|
| 02 Jul 2017 02:21 PM |
| So, I have a table. Inside the table will be all the players currently alive inside the minigame. But would I remove them when they die? |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 02 Jul 2017 02:28 PM |
| connect function death w/ removing name from table |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 02:37 PM |
Might work, but surely better way
while wait() do for i,plr in pairs(game.Players:GetChildren()) do Number = 0 plr = plr.Name if game.Workspace[plr].Humanoid.Health == 0 then for i=1,#TABLENAME do if TABLENAME[i] == plr then Number = i end end if Number ~= 0 then table.remove(TABLENAME,Number) end end end end |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 02 Jul 2017 02:40 PM |
You should record them all when you put them inside the minigame.
Once you do that, you would only get the players inside the minigame and use the .Died event of the Humanoid to subtract each player from the total number of players in the minigame. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 02:45 PM |
| I tried that. I just don't know how to remove them. |
|
|
| Report Abuse |
|
|
| |
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 02 Jul 2017 02:51 PM |
For example:
local yourListOfPlayers = {Player1, Player2, Player3}
for _, v in pairs(yourListOfPlayers) do v.Character.Humanoid.Died:connect(function () table.remove(yourListOfPlayers, v) end)
Not sure if this'll work. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 02:52 PM |
| that might work, but the script might wait forever waiting for the player to die? |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 02:54 PM |
| That is pretty much exactly what I'm doing, I'm using 'for' to go through all the current players inside the minigame, when they die I use table. remove() -- No space -- but I can't seem to get it to work. The output is: (number expected, got string) |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 02 Jul 2017 02:54 PM |
It won't wait forever, it just connects the event to each player.
I think that's OP's purpose, to remove them from the table once they die. |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 02 Jul 2017 02:55 PM |
Number expected, got string?
So somewhere in your script requires a number value, but instead received a string value.. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 02:58 PM |
| I used table. insert -- No space -- to add all the players into the table I didn't use a number, it is: table.insert(minigamePlayers, a.Name) -- A is the variable I used for all players. |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 02 Jul 2017 03:00 PM |
| So you're using their names to go through the players? Then for ################ ############## event you should do: game.Players[a.Name].Character.Humanoid.Died:connect(function () table.remove(minigamePlayers, a.Name) end) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2017 03:11 PM |
| ? I just tried using table.remove in the command bar and it only worked using Numbers. I could track them through user Id but I don't think that'll work. |
|
|
| Report Abuse |
|
|