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 » Scripting Helpers
Home Search
 

Re: Script Problem (Tables)

Previous Thread :: Next Thread 
Her0z is not online. Her0z
Joined: 04 Apr 2009
Total Posts: 1579
21 Jul 2011 06:32 PM
local players = game.Players:GetChildren()
for i = 1, #players do
table.insert(alive,players[i])
players[i].Character:MoveTo(Vector3.new(math.random(-107, 107), 98, math.random(-107, 107)))
players[i].Character.Humanoid.Died:connect(function()
alive[players[i]] = nil
print("Player Has Died")
end)
end
print(alive[1],alive[2])
wait(30)
print(alive[1],alive[2])

the print wen player dies is Player Has died, but after that (after 30 seconds) the print for the table is still Player nil, i need it to become nil nil when player dies, it seems to skip the alive[players[i]] = nil part
Report Abuse
Her0z is not online. Her0z
Joined: 04 Apr 2009
Total Posts: 1579
21 Jul 2011 06:44 PM
bump :PP
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
21 Jul 2011 06:49 PM
If what I understood was that alive was a table then why don't you use table.remove() ?
Report Abuse
Her0z is not online. Her0z
Joined: 04 Apr 2009
Total Posts: 1579
21 Jul 2011 06:55 PM
i dont want to remove the table, it will most likely be filled with other players names, not just one, and i want it to remove that players name if they die
Report Abuse
Her0z is not online. Her0z
Joined: 04 Apr 2009
Total Posts: 1579
21 Jul 2011 06:58 PM
nvm.... i just realized u might be meaning the complete oppisite of what im thinking... tables are annoying... :P, did u mean table.remove(table,players[i]) or did u mean remove all of the table
Report Abuse
Her0z is not online. Her0z
Joined: 04 Apr 2009
Total Posts: 1579
21 Jul 2011 07:10 PM
bump :P, table.remove(table,value) doesnt work :P
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
22 Jul 2011 05:13 AM
The first argument is the name of the table and the second is the position of the value you want to remove.
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
22 Jul 2011 05:15 AM
Try table.remove(alive, i)
Report Abuse
UttermostExedra is not online. UttermostExedra
Joined: 28 Dec 2009
Total Posts: 2483
22 Jul 2011 05:20 AM
alive = {}

local players = game.Players:GetChildren()
for i = 1, #players do
table.insert(alive,players[i].Name)
players[i].Character:MoveTo(Vector3.new(math.random(-107, 107), 98, math.random(-107, 107)))
players[i].Character:findFIrstChild("Humanoid").Died:connect(function()
table.remove(alive,players[i].Name)
print("Player Has Died")
end)
end
print(alive[1],alive[2])
wait(30)
print(alive[1],alive[2])
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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