OOP; how to get made class

I’m slowly trying to learn OOP (object oriented programming) right now, it’s going okay but I have a question,
Lets say you have this module script

local Person = {}
Person.__index = Person

function Person.new(Name)
    local self = {}

    self.Name = Name
    
    return setmetatable(self, Person)
end

function Person:PrintName()
     print(self.Name)
end

and say you have this server script

local PersonModule = require(script.PersonModule)

local Bob = PersonModule.new("Bob")

Would it be possible from another server script or module script to do Bob:PrintName()

Because I’m working on this project, and im trying to implement OOP but I need to do Bob:PrintName()
from another script, how would I go about doing this/or is this possible?

Thanks in advance,

1 Like

this should be exactly what you want

2 Likes

You just do exactly what you did since the beginning:

Put that object into a module script, which can be required by multiple other scripts to modify that object.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.