Person = {}
Person.__index = Person
Person.martialArts = {Karate = {}}
function Person.new(name, age, eth)
local newPerson = {
Name = name,
Age = age,
Ethnicity = eth,
martialArts = "Karate"
}
return setmetatable(newPerson, Person)
end
function Person.martialArts.Karate:Kick()
if self.martialArts == "Karate" then
print("Kick!")
else
return 0
end
end
function Person:Swim()
print(self.Name.. " is swimming!")
end
return Person
This is my running script:
Person = require(game.ReplicatedStorage.OOP)
local John = Person.new("John", "Young", "Human")
print(John.martialArts:Kick())
I get an error:
attempt to call method 'Kick' (a nil value)
I want to basically be able to do John.martialArts:Kick() and in that function it will check if he actually has the martial arts "Karate" and if he does, it will execute. I can't find any examples online about this and I've tried but I don't know how to get it to do that (what I'm trying to do). Any idea/help?

1 comment
It's supposed to be John.martialArts.Karate:Kick()