|
| 24 Apr 2017 04:55 PM |
| say theres a playeradded where you get added into a table when you join the game but once you leave how would I remove the player from that table? |
|
|
| Report Abuse |
|
|
| |
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 24 Apr 2017 05:30 PM |
table.remove or just redefine the table as game.Players:GetPlayers()
|
|
|
| Report Abuse |
|
|
|
| 24 Apr 2017 06:11 PM |
| i was thinking that.. .PlayerRemoving then table.remove but it doesnt let me remove the player.. it says it was expecting a number |
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 24 Apr 2017 07:14 PM |
you probably did table.remove(tab, player) you need to input a position in the table, and it seems your table's keys are integers and not objects (the player is an object). so just redefine it as game.Players:GetPlayers()
|
|
|
| Report Abuse |
|
|
|
| 24 Apr 2017 07:31 PM |
| redefine how? dont know how I would get :GetPlayers() in what im trying to do |
|
|
| Report Abuse |
|
|
|
| 24 Apr 2017 07:37 PM |
local players = game.Players:GetPlayers() --keep using :GetPlayers() instead of removing the player
|
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Apr 2017 07:50 PM |
I have a possible solution, it might not be the best but it could be something. This will only make the player in your table nil, nil is a standard of removing an object from the table. Pretty much what you may be looking for. -------------------------------------------------->> Script input -- implementing removed child -- "i" in the table is indicated for every object it has read passed. -- "v" is the object, allowing you to edit it's properties and such.
--Tab is for the players added into your table
-------------------------------------------------->> Code
local tab = {"Players that were in your table"}
game.Players.ChildRemoved:connect(function(player) for i,v in pairs(tab) do if v == player.Name then -- if you gather the player itself, do v.Name v = nil tab.sort -- organizes your table, removing the player from the table. -- removes the player from the table else -- add stuff, idk end end end) |
|
|
| Report Abuse |
|
|
|
| 24 Apr 2017 07:53 PM |
That's exactly why you would want to use GetPlayers.
|
|
|
| Report Abuse |
|
|
| |
|