How to remove key from table

Hi!

A little embarrassing, but I can’t figure out how to remove a key from a table  :unsure:

Lets say I create a table like this:

local playerTable = {} local params = { name = "Rob Miracle", age = 29, uselessInfo = "Nothing useful", } playerTable[#playerTable +1] = params

How to remove the key “uselessInfo” from this exact player later?

(I have tables with a lot of players and many params).

[lua]

playerTable[#playerTable].uselessInfo = nil

[/lua]

Ok, nilling out the key solves it, thanks!

I feel like deleting this post in embarrassment, but there might be another one missing this obvious solution  :ph34r:

Please leave it.

Rob

Well, you changed it from uselessInfo to params…playerTable[1].params doesn’t exist so nilling it out does nothing.

playerTable[1] becomes whatever params is, it doesn’t have params attached to it.

[lua]

local function removeKey(table, key)

  table[key] = nil

end

removeKey(playerTable[1], “uselessInfo”)

[/lua]

[lua]

playerTable[#playerTable].uselessInfo = nil

[/lua]

Ok, nilling out the key solves it, thanks!

I feel like deleting this post in embarrassment, but there might be another one missing this obvious solution  :ph34r:

Please leave it.

Rob

Well, you changed it from uselessInfo to params…playerTable[1].params doesn’t exist so nilling it out does nothing.

playerTable[1] becomes whatever params is, it doesn’t have params attached to it.

[lua]

local function removeKey(table, key)

  table[key] = nil

end

removeKey(playerTable[1], “uselessInfo”)

[/lua]