Trying to figure out how to insert values into table like this for an example:
stat= { plrname = {userid = 0, gold = 0) }
i know you use table.insert() but i haven't read that much about it
table.insert(stat, plrname)
^ that's the only thing I know, no clue how to add the userid and gold thanks for taking your time to help me out
table.insert
is for arrays not dictionaries. In this case you're trying to create a dictionary.
When writing a new index to a table, you can use the same notation for indexing a value but with a little extra. a[b] = c
; where a
is a table, b
is the key, and c
is the value.
local myTable = {} myTable["me"] = "cool"
This would result in a table that looks like this:
{ me = "cool" }