generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I need to keep track of all players in a minigame

Previous Thread :: Next Thread 
bosschaz1010 is not online. bosschaz1010
Joined: 28 May 2016
Total Posts: 167
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 is online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
02 Jul 2017 02:28 PM
connect function death w/ removing name from table
Report Abuse
FlamingGamez is not online. FlamingGamez
Joined: 22 Jan 2015
Total Posts: 354
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 is not online. 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
bosschaz1010 is not online. bosschaz1010
Joined: 28 May 2016
Total Posts: 167
02 Jul 2017 02:45 PM
I tried that. I just don't know how to remove them.
Report Abuse
FlamingGamez is not online. FlamingGamez
Joined: 22 Jan 2015
Total Posts: 354
02 Jul 2017 02:49 PM
Implement table.remove()
Report Abuse
BaiYuni is not online. 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
FlamingGamez is not online. FlamingGamez
Joined: 22 Jan 2015
Total Posts: 354
02 Jul 2017 02:52 PM
that might work, but the script might wait forever waiting for the player to die?
Report Abuse
bosschaz1010 is not online. bosschaz1010
Joined: 28 May 2016
Total Posts: 167
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 is not online. 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 is not online. 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
bosschaz1010 is not online. bosschaz1010
Joined: 28 May 2016
Total Posts: 167
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 is not online. 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
bosschaz1010 is not online. bosschaz1010
Joined: 28 May 2016
Total Posts: 167
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image