Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I remove players in tables?

Asked by 5 years ago

Tables are a very important part of some games. I sometimes even add players to tables! But there is a problem with that. I cant remove the layer from the table. Whenever I print the table, the data looks like:

table: 0x1a7105ac1e83c069

and I don't know how to remove that! I used player, player.Name, player.UserId, everything! please help me, and I would appreciate that!

0
You are printing the table address print(table) not the data in the table, you need to use a loop to print data inside the table or index it using arrays. greatneil80 2647 — 5y

1 answer

Log in to vote
3
Answered by
0_2k 496 Moderation Voter
5 years ago
Edited 5 years ago

There's two ways of doing this, one way consists of multi-line printing

local table1 = {"Jerry", "Squidward", "Spongebob"}

for _,v in pairs(table1) do
    print(v)
end

Here's another way, with one line printing

local table2 = {"Sandy", "Mr Krabs", "Plankton"}

print(unpack(table2));

To remove you'd do

local table = {"one", "two", "three", "four", "five"}

table.remove(table, 3) -- Would remove the 3rd argument which is "three"
Ad

Answer this question