So, I have been trying to make it so that if you state the instance in the “table.remove” it gets removed. But it does not work, it says it has to be an index in the array. How can I make it so instead of stating the index in the “table.remove(array, 2)” I can do “table.remove(array, Food)”?
script:
local Food = game.Workspace.Food
local array = {Food, 5.4352, game.Workspace.ColorLooping.Parent}
table.remove(array, 1) --I want this to remove the instance I name
--My wanted version: table.remove(array, Food)
print(array)
You need to state the the index in the “table.remove” to remove a value. But I want to state the instance itself: table.remove(array, Food) instead of table.remove(array, 1).
Here is the error I get while trying to do this:
ServerScriptService.Script:28: invalid argument #2 to 'remove' (number expected, got Instance)