Does this table remain

I was wondering even tho its a event and I don’t think it will, but does the table’s contents pass onto the other person who launches the same event ( server )

event.OnServerEvent:Connect(function(Player)
local table1 = {}
table.insert(table1, "blablabla")
end)

basically if someone uses that event will the table remain like that when the other player uses it and will they have in their table “blablabla” even if it wasn’t inserted?

No, the way I want to you to think abt it when u fire the event, everything in the callback function (the :Connect(function)...), will be ran, so since your defining an empty table inside it, that table will always be created regardless of which player fire the event. And when the function ends, if tht value has no further references, it will gced. (Garbage collected) i.e erased from memory. A thing to note is tht it won’t load a table with the smth inserted in it, it creates a table on the get-go.

EDIT: I realized tht i misunderstood ur question a little bit, so had to tweak it.

No, since this table is localized within the function, it will get garbage collected once it exits the scope (i.e when the function ends)

If you wanted it to remain then you’d have to take the local table1 = {} outside the function

1 Like