BankAccount(Id, Name, InitialAmount)
table.insert(CustomerDatabase, BankAccount)
Here, BankAccount
is a function, you are inserting into the table a function. That's why v.AccountName
is invalid, functions can't be indexed.
What you should do is to add the account object:
local account = BankAccount(Id, Name, InitialAmount)
table.insert(CustomerDatabase, account)