Reputation: 43
i'm currently learning LUA. My question is how to change the value in a table, i got nil:
my table is:
local players = {
{name = something, count = 1}
}
for _, current in ipairs(players) do
if current.name == inflictor.name then
local count = players[current].count --NIL
players[current].count = count + 1
break
end
end
thanks for the help
Upvotes: 1
Views: 966
Reputation:
In your ipairs
loop, _
is the key and current
is the value, which in this case is that table inside your players
table.
You'd fix that if you set either:
players[_].count
or just current.count
Upvotes: 2