local Apple = 'apple'
local Banana = 'banana'
local Orange = 'orange'
local function TableContents(Table)
for i = 1,#Table do
print(Table[i]) -- prints the contents of table
end
Table = nil -- Would this turn the original variable table to nil?
end
local function CreateTable()
local Table = {Apple,Banana,Orange}
TableContents(Table)
end
✓ ANSWER ACCEPTED
How would I make this table cleared, would it be nil?
2 answers
✓ Accepted answer
To answer to your question, no it would not set the original variable to nil. Why?
When you define the 'Table' argument as nil you're making the argument nil not the original table, consider defining it as nil within the function you defined it originally (after you call the other function) like so:
local function CreateTable()
local Table = {Apple,Banana,Orange} -- Create the Table
TableContents(Table) -- This sends 'Table' in as an argument
Table = nil -- This disposes of it.
end
Above function will create a new Table, pass it as an argument to your other function and define it as nil every time you call it.
Recreating the table itself should work. For instance
local Table1 = {}
table.insert(Table1, [1], game.Workspace.Part)
you can clear it by reinstating the table value.
local Table1 = {}
1 comment
0
Bad.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you salty for your detailed answer