game.Players.PlayerRemoving:connect(function(Player) table.remove(_G.Plyrs, Player.Name) end)
This is what I am doing but it's expecting a number rather than a string. Anyway to remove a player from a table easily?
That's because the table.remove method's second argument is the index value, meaning it won't search through the table to remove what you want..
Say I had this table;
tb = {1,2,3,4,5}
And I did;
tb = {"Hi","Bob",2} print(table.concat(tb," ")) > Hi Bob 2 table.remove(tb,2) print(table.concat(tb," ")) > Hi 2
It won't remove the index in the table named 2 it will remove the index in the table at that value.
So to fix your problem then you could do this;
val = nil for i,v in pairs(_G.Plyrs) if v == Player.Name then val = i end end --Now the variable 'val' will have the index number that you need to remove the desired object from your table. table.remove(_G.Plyrs,val)
-Goulstem