Attempt to call method 'remove' (a nil value) (SOLVED)

I’m new to dealing with tables in Lua, and tried doing:

table.remove(table, 1)

to remove the first element in the table “table”. When I do that and run the game I get this error:

ERROR:SCRIPT: /main/test.script:34: attempt to call method 'remove' (a nil value)
stack traceback:
	/main/test.script:34: in function </main/test.script:1>

“remove” seems to be a valid method, so I’m not quite sure what the problem is.

1 Like

to remove the first element in the table “table”.

Do not overwrite names like these. Instead name it “mytable”. That is the problem, you’ve overwritten “table” and all of its functions, which is why they no longer exist.

10 Likes

Thanks!

1 Like

Hi, I’m just passing by to say that your answer was still useful to me… 5 years after you posted it

4 Likes