badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 28 Jun 2014 02:30 PM |
(alive is a table, the function has been called and everything works except for the .Died function) can anyone help?
firstcheck = function() print("loaded") for _, check in pairs(plrs) do if check.PlayerGui.alive.Value == true then table.insert(alive,check) alive2 = table.getn(alive) print(alive2) else table.remove(alive,check) print(alive2) check.Character.Humanoid.Died:connect(function() table.remove(alive,check) print(alive2) end) end end end
|
|
|
| Report Abuse |
|
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
| |
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
| |
|
VoltiCoil
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 1227 |
|
|
| 30 Jun 2014 09:33 AM |
table.remove(alive,check) wrong
table.remove(alive,_) Correct.
You want to remove the number allocated to that plot on the table, not the name of it. think of _ as i:
firstcheck = function() print("loaded") for _, check in pairs(plrs) do if check.PlayerGui.alive.Value == true then table.insert(alive,check) alive2 = table.getn(alive) print(alive2) else table.remove(alive,_) print(alive2) check.Character.Humanoid.Died:connect(function() table.remove(alive,_) print(alive2) end) end end end
I've used a much more simpler method but we'll stick with yours. |
|
|
| Report Abuse |
|
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 30 Jun 2014 10:19 AM |
16:18:27.657 - Workspace.check_if_alive:9: bad argument #1 to 'insert' (table expected, got userdata) 16:18:27.657 - Script 'Workspace.check_if_alive', Line 9 - global firstcheck 16:18:27.657 - Script 'Workspace.check_if_alive', Line 46 16:18:27.657 - Stack End
table.insert(alive,check)
alive is a real table.
|
|
|
| Report Abuse |
|
|