This script is in my module(s):
Person = {}
Person.__index = Person
Person.martialArts = {}
function Person.new(name, age, ethnicity)
local newPerson = {}
setmetatable(newPerson,Person)
Person.Name = name
Person.Age = age
Person.Ethnicity = ethnicity
return newPerson
end
-- This is the area that is of problem, concern:
function Person.martialArts.new(style)
local newMartialArts = {}
setmetatable(newMartialArts,Person.martialArts)
style = {}
table.insert(Person.martialArts,style)
return newMartialArts
end
-- This area!
function Person:Swim()
print(self.Name.. " is swimming!")
end
return Person
See where I commented? This is the local script where I'm using this script/code:
Person = require(game.ReplicatedStorage.OOP)
local John = Person.new("John", "Young", "Human")
John.martialArts.new("Karate")
print(John.martialArts.Karate)
I'm trying to have it create a table called "Karate" inside martialArts for this particular person. But it won't create it and when it goes to print, the print says "nil." I don't know what I'm doing wrong.
For instance if I do John.martialArts.new("Karate") it should create the table "Karate" inside martialArts for John.
However, when doing print(John.martialArts.Karate), I simply get nil (whereas I should get an empty table value). Help?

2 comments
It's Lua.
Its Lua not LUA. Should probably edit before hiim comes